Commit 34ceb650 authored by Dexter Sapugay's avatar Dexter Sapugay

tried stuff out didnt work xD

parent a4cc4733
...@@ -14,8 +14,9 @@ Including another URLconf ...@@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path from django.urls import path, include
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('',include('IPSystemTOPC.urls')),
] ]
from django.db import models
class Upload(models.Model):
file = models.FileField(upload_to='EmployeeProdDB\IPSystemTOPC\Uploaded CSV')
\ No newline at end of file
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Upload</button>
</form>
\ No newline at end of file
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
\ No newline at end of file
from django.shortcuts import render, redirect
from .models import Upload
from django.shortcuts import render
def index(request):
return render(request, 'books/index.html')
def upload_file(request):
if request.method == 'POST':
form = Upload(request.POST, request.FILES)
if form.is_valid():
form.save()
return redirect('success_url')
else:
form = Upload()
return render(request, 'upload.html', {'form': form})
from django.contrib import admin
\ No newline at end of file
<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<title>Login</title>
<link rel="stylesheet" type='text/css' href="{% static 'css/style.css' %}"/>
</head>
<body>
{% block content %}
<div class="login-box">
<div class="login-logo">
<b>Voting System</b>
</div>
<div class="login-box-body">
<p class="login-box-msg">Sign in to start your session</p>
<form method="POST" action="{% url 'loginpage' %}">{% csrf_token %}
<div class="form-group has-feedback"></div>
<label for="username">Username: </label>
<input type="text" name="username" id="username">
</div>
<br>
<div>
<label for="password">Password: </label>
<input type="password" name="password" id="password">
</div>
<br>
<input type="submit">
</form>
<a href="{% url 'createaccount' %}"><button>SIGN UP HERE</button></a>
</div>
</div>
{% endblock content %}
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {{ form.as_p }}
<button type="submit">Upload</button> <button type="submit">Upload</button>
</form> </form>
</html>
\ No newline at end of file
from django.contrib import admin
from django.urls import path from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name='index'), path('admin/', admin.site.urls),
path('', views.login_page, name='loginpage'),
] ]
\ No newline at end of file
...@@ -11,17 +11,20 @@ from django.shortcuts import render ...@@ -11,17 +11,20 @@ from django.shortcuts import render
# ... # ...
# return render(request, 'uploadpage.html') # return render(request, 'uploadpage.html')
def upload_file(request): def login_page(request):
if request.method == 'POST': return render(request, 'loginpage.html')
form = Upload(request.POST.get('file'), request.FILES.get('file'))
if form.is_valid(): #def upload_file(request):
form.save() # if request.method == 'POST':
return redirect('success_url') # form = Upload(request.POST.get('file'), request.FILES.get('file'))
else: # if form.is_valid():
form = Upload() # form.save()
return render(request, 'uploadpage.html', {'form': form}) # return redirect('success_url')
# else:
def index(request): # form = Upload()
return render(request, 'employeeproddb/index.html') # return render(request, 'uploadpage.html', {'form': form})
#def index(request):
# return render(request, 'index.html')
...@@ -10,7 +10,8 @@ For the full list of settings and their values, see ...@@ -10,7 +10,8 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/ https://docs.djangoproject.com/en/4.0/ref/settings/
""" """
from pathlib import Path, os from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment