Login

Snippets by daemondazz

Snippet List

Active User Sorted ModelAdmin

Since r7806, the `User` field is unsorted which makes it harder to find specific users in the list if there is more than a few. This snippet is an `django.contrib.admin.ModelAdmin` subclass which searches through all of the fields on a form and automatically sorts fields which have a relation with `User`. It also filters on having `active=True`. Just import the `SortedActiveUserModelAdmin` class in your `admin.py` and subclass your `ModelAdmin` classes from it instead of `admin.ModelAdmin`.

  • sorting
  • modeladmin
  • user-foreign-key
Read More

daemondazz has posted 1 snippet.