[Fixed]-Adding a model in Django Admin to the User/Group models?

1👍

It’s a bit tricky, takes some work, and it’s going to trigger some warning in Django 1.8. But this is basically what you do:

Suppose you have an application myauth that will override the default django.contrib.auth application…

In myauth/models.py do this:

from django.db import models

from django.contrib.auth.models import User, Group


class ExtraModel(models.Model):
    ...

ExtraModel is the model you want to add.

In myauth/__init__.py do this:

from django.apps import AppConfig

class OverrideAuthConfig(AppConfig):
    name = 'auth'
    verbose_name = "New User and Authentication"

default_app_config = 'auth.OverrideAuthConfig'

In myauth/admin.py do this:

from django.contrib import admin

from .models import User, Group, ExtraModel

admin.site.register(User)
admin.site.register(Group)
admin.site.register(ExtraModel)

And in your settings.py, within INSTALLED_APPS comment out the line:

...
#'django.contrib.auth',
...

and just add your application:

...
'myauth',
...

This is the result

0👍

Try to override admin index template …

change this {% for app in app_list %} to {% for app in app_list reversed %} or sort it in some custom way …


EDIT

seems I’ve found easier solution 🙂

https://github.com/mishbahr/django-modeladmin-reorder

Leave a comment