Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ordering fields inside Inlines in Django Admin

Tags:

django

admin

I have a ManyToMany relationship setup with intermediary objects in Django. Any ideas how I can order the < select >s in the Inlines that show up for the intermediary objects?

like image 694
Yuvi Avatar asked May 28 '09 16:05

Yuvi


People also ask

How do I sort fields in Django admin?

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.

What is Inlines in Django?

The admin interface is also customizable in many ways. This post is going to focus on one such customization, something called inlines. When two Django models share a foreign key relation, inlines can be used to expose the related model on the parent model page. This can be extremely useful for many applications.

What is admin panel in Django?

One of the most powerful parts of Django is the automatic admin interface. It reads metadata from your models to provide a quick, model-centric interface where trusted users can manage content on your site. The admin's recommended use is limited to an organization's internal management tool.

How do I access my Django admin page?

To login to the site, open the /admin URL (e.g. http://127.0.0.1:8000/admin ) and enter your new superuser userid and password credentials (you'll be redirected to the login page, and then back to the /admin URL after you've entered your details).


1 Answers

You can use fields inside an InlineModelAdmin:

class FooInline(admin.StackedInline):
    model = Foo
    fields = ('field1', 'field2', 'field3')
like image 147
Arnaud Avatar answered Oct 15 '22 02:10

Arnaud