Yuvi
Yuvi

Reputation: 4637

Ordering fields inside Inlines in 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?

Upvotes: 6

Views: 4188

Answers (3)

Jay
Jay

Reputation: 702

I think this could be what you're looking for:

Orderable inlines using drag and drop with jQuery UI http://djangosnippets.org/snippets/1053/

Upvotes: 2

Arnaud
Arnaud

Reputation: 1815

Have you tried specifying a model for the many-to-many relationship using the through argument? You should be able to customize the admin with a ModelAdmin class then.

class A(models.Model):
      pass

class B(models.Model):
   m2m = models.ManyToManyField(A, through='C')

class C(models.Model):
    a = models.ForeignKey(A)
    b = models.ForeignKey(B)

Upvotes: 0

Arnaud
Arnaud

Reputation: 1815

You can use fields inside an InlineModelAdmin:

class FooInline(admin.StackedInline):
    model = Foo
    fields = ('field1', 'field2', 'field3')

Upvotes: 8

Related Questions