I am using Django 1.2.3. I was trying to check user permissions on a
certain model using the perms context variable from
contrib.auth.context_processors.auth. As per the documentation, I
tried this (foo is the app label, Bar is the model, and I'm using
default permissions):
{% if perms.foo.change_bar %} do stuff {% endif %}
It's always false even when logged in as a superuser. I tried doing
{{user.username}} to see if the user variable worked and it also
displayed nothing. So I checked in the debug toolbar and the variables
I get from the auth context processor are these:
{'messages':
<django.contrib.messages.storage.user_messages.LegacyFallbackStorage
object at 0xa38284c>,
'perms': <django.utils.functional.__proxy__ object at 0xa2f236c>,
'user': <django.utils.functional.SimpleLazyObject object at
0xa31748c>}
My questions are:
1) wasn't the SimpleLazyObject for user not fixed as claimed by ticket
12060 ( http://code.djangoproject.com/ticket/12060 ) ? Or was it fixed
after 1.2.3?
2) How do I go about checking permissions using the perms variable? It
seemed to be wrapped in some other function.
Please help.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment