Login

Tag "group"

Snippet List

Add custom fields to the built-in Group model

Add fields and extend Django's built-in `Group` model using a `OneToOneField` (i.e. a profile model). In this example, we add a `UUIDField`. Whenever a new group is created, we automatically (via signals) create a corresponding `Role` record referencing the newly created group. Whenever a Group is deleted, the corresponding Role is deleted as well.

  • model
  • group
  • uuid
  • signals
Read More

Group permissions selection in admin filtered by your app models

Sometimes you just don't want to display every permission django has, you just want a short list showing the permissions for some of your apps (or even django core apps). GROUP_PERMISSIONS_MODELS must be a list of your app models. Dotted path (in lowercase) required, app name + model *class* name.

  • admin
  • group
  • permissions
Read More

User groups template tag

This snippet is an improved version of the [ifusergroup](http://djangosnippets.org/snippets/1576/) tag that allows spaces in any of the group names. It also fixes a small bug where if a group didn't exist none of the subsequent groups would be checked.

  • tag
  • templatetag
  • user
  • auth
  • group
  • permissions
  • access-control
Read More

User groups template tag

This tag builds on top of the [ifusergroup/else tag](http://www.djangosnippets.org/snippets/390/), fixes a small bug and introduces support for else blocks. This adds a way to provide multiple groups via group1|group2|group3

  • tag
  • templatetag
  • user
  • auth
  • group
Read More

LDAP to Django Synchronization

I needed to be able to synchronize my LDAP users and groups to the Django database. This may not be as efficient as some might like but it works like a charm. It returns a list of messages that I pipe into request.user.messages in my template.

  • user
  • auth
  • ldap
  • group
Read More

in_group template filter

Allows you to search if a user belongs to a given group. Along the same lines as snippet [390](http://www.djangosnippets.org/snippets/390/), but uses a regular ``if`` tag so it is more flexible. (Updated for efficiency. Running a boolean test on a QuerySet avoids a bit of unnecessary overhead.) (Updated to accept a list of groups.)

  • template
  • filter
  • group
Read More

11 snippets posted so far.