Stealthy Stan
Stealthy Stan

Reputation: 433

Django Group Admin Interface

I recently updated to a custom user model, and am now using the built in Group class like so in my models.py file:

groups = models.ManyToManyField(
    Group,
    help_text='Highlighted groups are the ones this user is a member of.',
    blank=True
)

Now, this is what my admin interface looks like:

enter image description here

While this is functional, it is annoying because I can easily misclick and lose all group membership for a particular user, forgetting what groups they were a member of.

Before I created the custom user model, I had the option to click a group on the left, then press add and it would show up in a totally separate table to the right, with that users current groups.

Here is my attempt to illustrate that with Paint...(pretending they are a member of 'Fake22' and you are about to add them to 'Fake' and 'Hi StackOverfloW')

enter image description here

This feature was extremely helpful for me. If anyone knows how I can recapture this through Django please let me know. I have gotta believe that because Django used to take care of this, there is no reason it can't anymore.

Essentially, how can I get this feature back? Or a do it yourself alternative could work...

If you need any more information please ask! For example, I could provide code from admin.py! Just let me know.

Upvotes: 1

Views: 738

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599788

You should define the filter_horizontal attribute on the ModelAdmin. See the documentation.

Upvotes: 1

Related Questions