Let's say I have my pizza application with Topping and Pizza classes and they show in Django Admin like this:
PizzaApp - Toppings >>>>>>>>>> Add / Change Pizzas >>>>>>>>>> Add / Change
But I want them like this:
PizzaApp - Pizzas >>>>>>>>>> Add / Change Toppings >>>>>>>>>> Add / Change
How do I configure that in my admin.py?
You can order the fields as you wish using the ModelAdmin. fields option. The order of fields would depend on the order in which you declare them in your models. So alternatively you could order the fields in the way you would want them to show in the admin.
The Django admin application can use your models to automatically build a site area that you can use to create, view, update, and delete records. This can save you a lot of time during development, making it very easy to test your models and get a feel for whether you have the right data.
A workaround that you can try is tweaking your models.py as follows:
class Topping(models.Model): . . . class Meta: verbose_name_plural = "2. Toppings" class Pizza(models.Model): . . . class Meta: verbose_name_plural = "1. Pizzas"
Not sure if it is against the django's best practices but it works (tested with django trunk).
Good luck!
PS: sorry if this answer was posted too late but it can help others in future similar situations.
If you want to solve this in 10 seconds just use spaces in verbose_name_plural, for example:
class Topping(models.Model): class Meta: verbose_name_plural = " Toppings" # 2 spaces class Pizza(models.Model): class Meta: verbose_name_plural = " Pizzas" # 1 space
Of course it isn't ellegant but may work for a while before we get a better solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With