Imagine we have a model like this:
class Container(models.Model): name = models.CharField(max_length=60) class Element(models.Model): container = models.ForeignKey(Container, blank=True, null=True)
Container is One; Element is many.
In Django admin, if I add a StackedInline with model=Element to the inlines the Container model admin:
class Inline(admin.StackedInline): model = Element class ContainerAdmin(admin.ModelAdmin): inlines = (Inline,) admin.site.register(Container, ContainerAdmin)
As a result, I get a set of forms that allows you to enter a new Element object in the Add Container form.
Instead, I would like to get the selected widget to select existing Element objects.
Is this possible without the introduction of an additional model?
source share