Automatically write `admin.py` using `admin_generator` command of `django-extensions`

Tram Ho

What i want to do:

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

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 models.py.

What is django-extension?

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

Install

Add in to settings.py

  • pj_name/settings.py

Execute

Overwrite the output result in admin.py.

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

Result

For example:

This class:

Will be looking like this:

Create user to login on management screen

Start the local server

Access to this address: http://127.0.0.1:8000/admin/

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

Share the news now

Source : Viblo