Django admin: how do I add an unrelated model field to a model change/add page?
- by NP
I have the following models:
class Foo(models.Model):
field1 = models.IntegerField()
...
class Bar(models.Model):
field1 = models.IntegerField()
...
class Foo_bar(models.Model):
foo = models.ForeignKey(Foo)
bar = models.ForeignKey(Bar)
...
In the admin, I want it so that in the Foo change/add page, you can specify a Bar object, and on save I want to create a Foo_bar object to represent the relationship. How can I do this through customizing the Admin site/ModelAdmins? Thanks.