basic upload test
This commit is contained in:
parent
b89f96c57c
commit
d907467561
@ -1,3 +1,16 @@
|
|||||||
from django.shortcuts import render
|
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 = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [],
|
'DIRS': ['templates'],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
|
@ -2,9 +2,7 @@ from django.conf.urls import include, url
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# Examples:
|
|
||||||
# url(r'^$', 'web.views.home', name='home'),
|
|
||||||
# url(r'^blog/', include('blog.urls')),
|
|
||||||
|
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
|
|
||||||
|
url(r'^fitnotes-upload/$', 'lifting.views.fitnotes_upload'),
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user