I'm having some issues configuring the following setup in the Django admin.
Setup:
Lets say i have the following Django models:
class Food(models.Model):
section = models.ManyToManyField(Section, related_name='foods')
class Fruit(Food):
pass
class Meat(Food):
pass
Then another model which allows the end user to give custom names to sections and assign the appropriate model to that section:
class Section(models.Model):
FOOD = 'FO'
FRUIT = 'FR'
MEAT = 'ME'
MODEL_CHOICES = (
(FOOD, 'Food'),
(FRUIT, 'Fruit'),
(MEAT, 'Meat'),
)
name = models.CharField(max_length=20)
model = models.CharField(max_length=2,
choices=MODEL_CHOICES,
default=FIELDS)
The user defines the following custom sections in the database:
name = Oranges model = Fruit
name = Apples & Pears model = Fruit
name = Organic beef model = Meat
name = Regular beef model = Meat
Currently:
In the admin we get the following:
Foods
Meats
Fruits
Sections
The admin allows us to add a meat or a fruit and assign it to a custom section, but this would require the data entry person to know if Oranges are a fruit or a meat. I'm just not willing to leave that to chance, ya know..
For example the current order of operations is this:
admin -> add Fruit item -> Name it Blood Orange & assign it to the Oranges section
What i would like to do:
I would like the admin to list the custom section names so that the user can choose to add an item to one of these user created sections:
Oranges (user defined)
Apples & Pears (user defined)
Organic beef (user defined)
Regular beef (user defined)
Sections
Now, when the user chooses to add an orange to the database via admin the fruit form would be supplied and Organic beef would supply the meat form. So the order of operations to be:
admin -> add Orange -> Name it Blood Orange
I can certainly write a custom interface for this, but i was hoping that this could easily implemented in the django admin interface?