Automatically write `` using `admin_generator` command of `django-extensions`

What i want to do:

If there are many tables, it will be difficult to write to

I want you it to be done automatically.

If we use the admin_generator command of the library called django-extensions, it can be done automatically.

It really does his job regarding the contents of

What is django-extension?

django-extensions extends the functionality of, and there are various other commands.


$ pip install django-extensions

Add in to

  • pj_name/

    'django_extensions', # <- 追記


Overwrite the output result in

$APP contains the application name created with $python startapp xxx.

$ python admin_generator $APP > $APP/


For example:

This class:

class Users(models.Model):
    user_name = models.CharField(max_length=255)
    last_name = models.CharField(max_length=255)
    first_name = models.CharField(max_length=255)
    email = models.CharField(max_length=255)
    created_at = models.DateTimeField()
    updated_at = models.DateTimeField()
    del_flg = models.IntegerField()

    class Meta:
        managed = False
        db_table = 'users'

Will be looking like this:

class UsersAdmin(admin.ModelAdmin):
    list_display = (
    list_filter = ('created_at', 'updated_at')
    date_hierarchy = 'created_at'

Create user to login on management screen

$ python createsuperuser

Username (leave blank to use 'your_home_dir'): <- any name as you wish
Email address: 
Password (again): 
Superuser created successfully.

Start the local server

$ python runserver

Access to this address:

It is OK if the login table is displayed with the user information created earlier.

All Rights Reserved