Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#16588 closed Cleanup/optimization (fixed)

Field called 'clean' causes cryptic error

Reported by: anonymous Owned by: nobody
Component: Documentation Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Change History (4)

comment:1 by anonymous, 13 years ago

Summary: Field called 'clean'Field called 'clean' causes cryptic error

comment:2 by Aymeric Augustin, 13 years ago

Component: contrib.adminDocumentation
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

In hindsight, it's obvious that calling a field clean, save or delete 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/

Version 0, edited 13 years ago by Aymeric Augustin (next)

comment:3 by Tim Graham <timograham@…>, 12 years ago

Resolution: fixed
Status: newclosed

In dd0cbc6bdccfc51329427b8a6023f6e866d48cba:

Fixed #16588 - Warned about field names that conflict with the model API

comment:4 by Tim Graham <timograham@…>, 12 years ago

In a1d21c08774c87b8d2995aada5ad20c650ad7570:

[1.4.X] Fixed #16588 - Warned about field names that conflict with the model API

Backport of dd0cbc6bdc from master

Note: See TracTickets for help on using tickets.
Back to Top