I have an application that has defined these models:
class Manufacturer(models.Model):
manufacturer = models.CharField(max_length=40, unique=True)
def __str__(self):
return self.manufacturer
and
class DeviceModel(models.Model):
model = models.CharField(max_length=20, unique=True)
manufacturer = models.ForeignKey(Manufacturer, to_field='manufacturer')
def __str__(self):
return self.model
I'm using django-treebeard, so I would like to add any newly added Manufacturer or DeviceModel into the tree hierarchy defined by:
class DeviceList(MP_Node):
name = models.CharField(max_length=30)
node_order_by = ['name']
def __unicode__(self):
return 'DeviceList: %s' %
self.name I was thinking that a good place to do that is in the admin page. When adding the manufacturer, it should save the new object Manufacturer into the table Manufacturer, and also create a new entry in the DeviceList table.
How do I do this two-fold save using the admin page?