Field called 'clean' causes cryptic error
Naming a field 'clean' causes a rather cryptic message when adding a object through the admin interface. The error is "'NoneType' object is not callable".
Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/options.py" in wrapper
307. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py" in _wrapped_view
93. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
79. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in inner
197. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py" in _wrapper
28. return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py" in _wrapped_view
93. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py" in bound_func
24. return func(self, *args2, **kwargs2)
File "/usr/local/lib/python2.6/dist-packages/django/db/transaction.py" in inner
217. res = func(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/options.py" in add_view
864. if form.is_valid():
File "/usr/local/lib/python2.6/dist-packages/django/forms/forms.py" in is_valid
121. return self.is_bound and not bool(self.errors)
File "/usr/local/lib/python2.6/dist-packages/django/forms/forms.py" in _get_errors
112. self.full_clean()
File "/usr/local/lib/python2.6/dist-packages/django/forms/forms.py" in full_clean
269. self._post_clean()
File "/usr/local/lib/python2.6/dist-packages/django/forms/models.py" in _post_clean
331. self.instance.clean()
Exception Type: TypeError at /admin/library/song/add/
Exception Value: 'NoneType' object is not callable
In hindsight, it's obvious that calling a field
clean
,save
ordelete
won't work as expected.The docs could warn about such conflicts between field names and the model API: https://docs.djangoproject.com/en/dev/ref/models/instances/