Created
August 31, 2014 10:04
-
-
Save CapnKernel/3c3e02ba69eb7553a28b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| request.POST= <QueryDict: {u'go': [u'Go'], u'csrfmiddlewaretoken': [u'N95FTIcEVsslOCSdP3pPhmYlQBaOj2me'], u'flag1': [u'on']}> | |
| form= {'files': {}, 'is_bound': True, 'error_class': <class 'django.forms.util.ErrorList'>, 'empty_permitted': False, 'fields': {'flag1': <django.forms.fields.BooleanField object at 0x7f606c0320d0>, 'flag2': <django.forms.fields.BooleanField object at 0x7f606c032d90>}, 'initial': {}, 'label_suffix': u':', 'prefix': None, '_changed_data': None, 'data': <QueryDict: {u'go': [u'Go'], u'csrfmiddlewaretoken': [u'N95FTIcEVsslOCSdP3pPhmYlQBaOj2me'], u'flag1': [u'on']}>, '_errors': None, 'auto_id': u'id_%s'} | |
| [31/Aug/2014 10:03:44] "POST / HTTP/1.1" 500 71727 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>My trivial page</title> | |
| </head> | |
| <body> | |
| <h1>My trivial page</h1> | |
| <form method="POST"> | |
| {% csrf_token %} | |
| <table> | |
| {{ form }} | |
| </table> | |
| <input type="submit" name="go" value="Go" /> | |
| </form> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Environment: | |
| Request Method: POST | |
| Request URL: http://localhost:8001/ | |
| Django Version: 1.5.7 | |
| Python Version: 2.7.5 | |
| Installed Applications: | |
| ('django.contrib.admin', | |
| 'django.contrib.auth', | |
| 'django.contrib.contenttypes', | |
| 'django.contrib.sessions', | |
| 'django.contrib.messages', | |
| 'django.contrib.staticfiles', | |
| 'trivial') | |
| Installed Middleware: | |
| ('django.contrib.sessions.middleware.SessionMiddleware', | |
| 'django.middleware.common.CommonMiddleware', | |
| 'django.middleware.csrf.CsrfViewMiddleware', | |
| 'django.contrib.auth.middleware.AuthenticationMiddleware', | |
| 'django.contrib.messages.middleware.MessageMiddleware', | |
| 'django.middleware.clickjacking.XFrameOptionsMiddleware') | |
| Traceback: | |
| File "/home/mjd/git/env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response | |
| 115. response = callback(request, *callback_args, **callback_kwargs) | |
| File "/home/mjd/git/django-trivial/trivial/trivial/views.py" in main | |
| 14. assert form.is_valid() | |
| Exception Type: AssertionError at / | |
| Exception Value: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.shortcuts import render | |
| from django import forms | |
| class FlagsForm(forms.Form): | |
| flag1 = forms.BooleanField(initial=True) | |
| flag2 = forms.BooleanField(initial=False) | |
| def main(request): | |
| if request.method == 'POST': | |
| print "request.POST=", request.POST | |
| form = FlagsForm(request.POST) | |
| print "form=", form.__dict__ | |
| assert form.is_valid() | |
| form = FlagsForm() | |
| return render(request, 'page.html', {'form': form}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment