I always found the edit_inline syntax quite strange. So, I decided to try something different: let the inline models be configured in the model itself, not in the children models. I came up with the given patch, which basically allows the use of inline models the following way:
class Person(models.Model):
name = models.CharField(maxlength=20)
class Admin:
inline_models = (
{'model':'Child',
'type':models.TABULAR,
'min_num_in_admin':3,
'max_num_in_admin':20,
'num_extra_on_change':3,
'fields':('name','age',)
},
{'model':'Job',
'type':models.STACKED,
'min_num_in_admin':1,
'max_num_in_admin':3,
'fields':('company','salary',)
}
)
class Child(models.Model):
parent = models.ForeignKey(Person)
name = models.CharField(maxlength=100)
age = models.IntegerField()
hair_color = models.CharField(maxlength=20,blank=True,null=True)
class Job(models.Model):
person = models.ForeignKey(Person)
company = models.CharField(maxlength=100)
salary = models.IntegerField()
section = models.CharField(maxlength=50)