> I'm trying to figure out whether I can use Django's built in auth
> system for my needs.  I need to limit access to certain areas
> depending on whether the user is member of particular groups.  Not
> groups as in whether they area admins, moderators etc, but more in a
> social network type sense of the word groups.
> 
> How would I go about adding my own methods, something like:
> 
> request.user.is_member_of(group)

Yes, Django's built-in auth system will do what you describe.  An
"auth method" isn't, however, what you want.  Django does support
additional "auth methods" as I discovered just yesterday when I
needed to support one-time hash authentication.

It sounds like all you need is to create your own decorator like
the login_required or user_passes_test functions found in
django/contrib/auth/decorators.py

Django already has support for groups and per-user permissions on
the User object, so the permission_required decorator (also in
the above-mentioned file) may already do what you want.  Or, you
can copy the permission_required decorator and make your own
"group_required" decorator in 2-5 lines of code.

-tim




--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to