basic upload test

This commit is contained in:
James Turk 2015-04-01 18:19:20 -04:00
parent b89f96c57c
commit d907467561
4 changed files with 22 additions and 6 deletions

View File

@ -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
View File

@ -0,0 +1,5 @@
<form method="post">
{% csrf_token %}
{{form}}
<input type="submit" />
</form>

View File

@ -39,7 +39,7 @@ ROOT_URLCONF = 'web.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': ['templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [

View File

@ -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'),
]