[Django]-Django ManyToMany Inlines Ordering in 1.2.x

3👍

The model ordering meta option designates the order of the inline elements.

class Foo(models.Model):
    name = models.CharField(max_length=100)

    class Meta:
        ordering = ('name',)

If you needed to have the ordering of the admin model different from your primary ordering, you could do something like this:

class Foo_Extended(Foo):
    class Meta:
        ordering = ('name',)

And use Foo_Extended for your AdminInline model.

I’m assuming you know this, but Django 1.3 adds and ordering option to the InlineAdmin model but I know you said Django 1.2

0👍

I think you may override

ModelAdmin.formfield_for_foreignkey(self, db_field, request, **kwargs)

You can find details in the docs for ModelAdmin.formfield_for_foreignkey.

👤yufeng

Leave a comment