Hi there,

 I've a context_processor to automatically add to each template a
object which says to me if a given user is memeber of an admin group.
It works fine when user is authenticated (whichever groups he belongs
to) but raise an AttributeError when user is not.

"Nonetype has no attribute _meta" in models.query (get_meta method)

Here is my context_processor code :

--------------- CODE ------------------

def is_gestion(request):

    try:
        return {'gestion': request.user.groups.get
(name=settings.BAOBAB_ADMIN_GROUP)}
    except Group.DoesNotExist:
        if request.user.is_superuser:
            return {'gestion': True}
        else:
            return {'gestion': False}


----------------- CODE -----------------------

and here the my pasted trace :
http://dpaste.com/69576/

It appears that an AnonymousUser has an EmptyManager connected to its
groups attribute.

 AFAICS, this manager permits to keep the code applied to an
authenticated user valid even if an anonymous user is here.

 (eg we have more or less the same attributes on both User and
AnonymousUser objects).

 How can I handle the groups relation in this way ?

Thanks a lot

 Frédéric



--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to