Django admin: how do I add an unrelated model field to a model change/add page?
Posted
by NP
on Stack Overflow
See other posts from Stack Overflow
or by NP
Published on 2010-05-17T22:32:28Z
Indexed on
2010/05/17
22:40 UTC
Read the original article
Hit count: 230
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.
© Stack Overflow or respective owner