Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Catching validation errors in django forms

By: ChipT on Jan 25th, 2012  |  syntax: None  |  size: 2.27 KB  |  views: 50  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Environment:
  2.  
  3. Request Method: POST
  4. Request URL: http://127.0.0.1:8000/testone/
  5. Django Version: 1.2.7
  6. Python Version: 2.7.2
  7. Installed Applications:
  8. ['django.contrib.auth',
  9.  'django.contrib.contenttypes',
  10.  'django.contrib.sessions',
  11.  'django.contrib.sites',
  12.  'django.contrib.markup',
  13.  'mydb.movies',
  14.  'django.contrib.admin',
  15.  'mydb.databrowse',
  16.  'registration',
  17.  'reversion',
  18.  'haystack',
  19.  'hitcount',
  20.  'debug_toolbar',
  21.  'chronograph',
  22.  'change_email',
  23.  'favorites',
  24.  'blog']
  25. Installed Middleware:
  26. ('django.middleware.common.CommonMiddleware',
  27.  'django.contrib.sessions.middleware.SessionMiddleware',
  28.  'django.contrib.auth.middleware.AuthenticationMiddleware',
  29.  'django.middleware.transaction.TransactionMiddleware',
  30.  'reversion.middleware.RevisionMiddleware',
  31.  'breadcrumbs.middleware.BreadcrumbsMiddleware',
  32.  'debug_toolbar.middleware.DebugToolbarMiddleware')
  33.  
  34.  
  35. Traceback:
  36. File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
  37.   100.                     response = callback(request, *callback_args, **callback_kwargs)
  38. File "c:\development\python\mydb\movies\views.py" in testone
  39.   1664.                 if form.is_valid(): # All validation rules pass
  40. File "C:\Python27\lib\site-packages\django\forms\forms.py" in is_valid
  41.   121.         return self.is_bound and not bool(self.errors)
  42. File "C:\Python27\lib\site-packages\django\forms\forms.py" in _get_errors
  43.   112.             self.full_clean()
  44. File "C:\Python27\lib\site-packages\django\forms\forms.py" in full_clean
  45.   269.         self._post_clean()
  46. File "C:\Python27\lib\site-packages\django\forms\models.py" in _post_clean
  47.   320.         self.instance = construct_instance(self, self.instance, opts.fields, opts.exclude)
  48. File "C:\Python27\lib\site-packages\django\forms\models.py" in construct_instance
  49.   51.             f.save_form_data(instance, cleaned_data[f.name])
  50. File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py" in save_form_data
  51.   416.         setattr(instance, self.name, data)
  52. File "C:\Python27\lib\site-packages\django\db\models\fields\related.py" in __set__
  53.   325.                                 (instance._meta.object_name, self.field.name))
  54.  
  55. Exception Type: ValueError at /testone/
  56. Exception Value: Cannot assign None: "Film.studio" does not allow null values.
clone this paste RAW Paste Data