From ee73906580849e701d09330dfd749ae586f42e82 Mon Sep 17 00:00:00 2001 From: zhijiasun Date: Wed, 4 Jun 2014 22:58:18 +0800 Subject: [PATCH] learn the crispy_forms app --- formtest/templates/form.html | 7 ++++--- formtest/views.py | 8 ++++---- notes.txt | 2 ++ tutorial/settings.py | 3 +++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/formtest/templates/form.html b/formtest/templates/form.html index 15d8e29..c317df6 100644 --- a/formtest/templates/form.html +++ b/formtest/templates/form.html @@ -4,9 +4,10 @@ +{% load crispy_forms_tags %}
{% csrf_token %} - {{ form.as_p }} - + {{ form|crispy }} +
- \ No newline at end of file + diff --git a/formtest/views.py b/formtest/views.py index 4712567..1e8c0bf 100644 --- a/formtest/views.py +++ b/formtest/views.py @@ -8,9 +8,9 @@ def contact(request): if request.method == "POST": print 'aaaaaaaaaa' - form = Contact(request.POST) - if form.is_valid(): + myform = Contact(request.POST) + if myform.is_valid(): return HttpResponseRedirect('/thanks/') else: - form = Contact() - return render(request,'form.html',{'form':form,}) \ No newline at end of file + myform = Contact() + return render(request,'form.html',{'form':myform,}) diff --git a/notes.txt b/notes.txt index 9dbf1af..83e28c7 100644 --- a/notes.txt +++ b/notes.txt @@ -8,3 +8,5 @@ issue during the coding templates/index.html in formtest app, it always find testuser/templates/index.html instead of formtest/templates/index.html, this is not corrcet. + +2.how to structure the tempaltes and static directory ? diff --git a/tutorial/settings.py b/tutorial/settings.py index 617f17e..8e2c555 100644 --- a/tutorial/settings.py +++ b/tutorial/settings.py @@ -52,6 +52,7 @@ 'registration_defaults', 'rest_auth', 'cbv', #class based views tutorial + 'crispy_forms', ) MIDDLEWARE_CLASSES = ( @@ -118,3 +119,5 @@ } REST_REGISTRATION_BACKEND = 'registration.backends.simple.views.RegistrationView' # REST_PROFILE_MODULE = 'accounts.UserProfile' + +CRISPY_TEMPLATE_PACK = 'bootstrap3'