Skip to content

Commit

Permalink
learn the crispy_forms app
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijiasun committed Jun 4, 2014
1 parent a5069b5 commit ee73906
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
7 changes: 4 additions & 3 deletions formtest/templates/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
<title>
</title>
<body>
{% load crispy_forms_tags %}
<form action="/formtest/form/" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit"/>
{{ form|crispy }}
<!-- <input type="submit" value="Submit"/> -->
</form>
</body>
</body>
8 changes: 4 additions & 4 deletions formtest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,})
myform = Contact()
return render(request,'form.html',{'form':myform,})
2 changes: 2 additions & 0 deletions notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
3 changes: 3 additions & 0 deletions tutorial/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
'registration_defaults',
'rest_auth',
'cbv', #class based views tutorial
'crispy_forms',
)

MIDDLEWARE_CLASSES = (
Expand Down Expand Up @@ -118,3 +119,5 @@
}
REST_REGISTRATION_BACKEND = 'registration.backends.simple.views.RegistrationView'
# REST_PROFILE_MODULE = 'accounts.UserProfile'

CRISPY_TEMPLATE_PACK = 'bootstrap3'

0 comments on commit ee73906

Please sign in to comment.