Sometimes the admin site works great out of the box. Other times, you need to add some custom code to certain parts of your admin site.
Maybe, you want some custom tables that shows your revenue for the month (i.e. you have an e-commerce site), maybe you’d like to create a button so you could upload batch SKUs for product inventory in your e-commerce site.
The sky really is the limit. This post will show you not only how to update and custom the admin templates, but it will also give you a clue to how to update the actual admin views so you can change the behavior of the entire admin interface.
Step 1: Override Admin Templates
Create a an admin directory in your project’s templates directory. Create a subdirectory inside of the admin directory that will be the name of your app (i.e. my_app).
You have some options that you could edit for specific apps:
All the other ones, you would just copy into your newly created admin directory.
Step 2: Override Admin View by Subclassing AdminSite
If you’d like to change how your Admin site behaves, you’ll need to subclass
Any method or attribute you find here can be overridden. You can literally change how the entire Admin site behaves and works.
Step 3: Instantiate your Admin Class and Register your Models on it
Once your admin site works the way you want it to, you can instantiate and register your models to it:
Now, you can add your admin to your urlconf:
Now, you can change the look and feel of you admin site, and even update the behavior of the entire admin site. What would you like to add to your site?