basic upload test
This commit is contained in:
parent
b89f96c57c
commit
d907467561
@ -1,3 +1,16 @@
|
||||
from django.shortcuts import render
|
||||
from django import forms
|
||||
|
||||
# Create your views here.
|
||||
|
||||
class FitnotesUploadForm(forms.Form):
|
||||
file = forms.FileField()
|
||||
|
||||
|
||||
def fitnotes_upload(request):
|
||||
if request.method == 'POST':
|
||||
form = FitnotesUploadForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
print(request.FILES['file'])
|
||||
else:
|
||||
form = FitnotesUploadForm()
|
||||
return render(request, 'upload.html', {'form': form})
|
||||
|
5
templates/upload.html
Normal file
5
templates/upload.html
Normal file
@ -0,0 +1,5 @@
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{form}}
|
||||
<input type="submit" />
|
||||
</form>
|
@ -39,7 +39,7 @@ ROOT_URLCONF = 'web.urls'
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'DIRS': ['templates'],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
|
@ -2,9 +2,7 @@ from django.conf.urls import include, url
|
||||
from django.contrib import admin
|
||||
|
||||
urlpatterns = [
|
||||
# Examples:
|
||||
# url(r'^$', 'web.views.home', name='home'),
|
||||
# url(r'^blog/', include('blog.urls')),
|
||||
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
|
||||
url(r'^fitnotes-upload/$', 'lifting.views.fitnotes_upload'),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user