#14283: AttributeError: 'NoneType' object has no attribute 'user' on admin
detail
page
-------------------------------------+--------------------------------------
Reporter: [email protected] | Owner: nobody
Status: new | Milestone:
Component: Uncategorized | Version: 1.2
Keywords: | Stage: Unreviewed
Has_patch: 0 |
-------------------------------------+--------------------------------------
After updating to the latest Django version (r13840), I am getting strange
errors when displaying the admin detail page for some of my models. I
haven't touched my own admin or model classes for a while, so I suspect
this could be a bug in a recent Django changeset. I am not very familiar
with this part of Django, but it seems like the request object is not
passed through correctly.
Here is the traceback:
{{{
Traceback (most recent call last):
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/core/handlers/base.py", line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/contrib/admin/options.py", line 245, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/utils/decorators.py", line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/views/decorators/cache.py", line 69, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/contrib/admin/sites.py", line 190, in inner
return view(request, *args, **kwargs)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/utils/decorators.py", line 21, in _wrapper
return decorator(bound_func)(*args, **kwargs)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/utils/decorators.py", line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/utils/decorators.py", line 17, in bound_func
return func(self, *args2, **kwargs2)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/db/transaction.py", line 299, in _commit_on_success
res = func(*args, **kw)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/contrib/admin/options.py", line 913, in change_view
for FormSet, inline in zip(self.get_formsets(request, obj),
self.inline_instances):
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/contrib/admin/options.py", line 421, in get_formsets
yield inline.get_formset(request, obj)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/contrib/contenttypes/generic.py", line 403, in get_formset
return generic_inlineformset_factory(self.model, **defaults)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/contrib/contenttypes/generic.py", line 369, in
generic_inlineformset_factory
fields=fields, exclude=exclude, max_num=max_num)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/forms/models.py", line 685, in modelformset_factory
formfield_callback=formfield_callback)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/forms/models.py", line 423, in modelform_factory
return ModelFormMetaclass(class_name, (form,), form_class_attrs)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/forms/models.py", line 227, in __new__
opts.exclude, opts.widgets, formfield_callback)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/forms/models.py", line 185, in fields_for_model
formfield = formfield_callback(f, **kwargs)
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/contrib/admin/options.py", line 113, in
formfield_for_dbfield
related_modeladmin.has_add_permission(request))
File "/usr/local/python-2.6/lib/python2.6/site-
packages/django/contrib/admin/options.py", line 292, in has_add_permission
return request.user.has_perm(opts.app_label + '.' +
opts.get_add_permission())
AttributeError: 'NoneType' object has no attribute 'user'
}}}
Looking through the recent changes in Django trunk, I see that r13731
changed fields_for_model in django.forms.models, which is also in the
traceback. Could this have something to do with it?
For reference, here is my model admin class:
{{{
class EventAdmin(dj_admin.ModelAdmin):
model = my_models.Event
inlines = [metadata_admin.CommentInline, metadata_admin.RatingInline,
metadata_admin.TagInline]
date_hierarchy = 'created'
raw_id_fields = ['owner', 'image', 'address']
list_display = ['title', 'owner', 'created', 'is_active', 'is_hidden',
'community']
list_filter = ['is_highlighted', 'community']
fieldsets = [
(None, {'fields': ['owner', 'community', ('start', 'end'),
'title', 'description', 'address', 'image', ('is_hidden', 'is_active'),
'is_highlighted', 'license']}),
(u'Statistiken', {'fields': ['views', 'num_comments',
'num_ratings', 'average_rating'], 'classes': ['collapse']})
]
save_on_top = True
search_fields = ['title']
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/14283>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.