Hi, i need pre-populete tabular inline in admin what is the best ways
example
class Options(models.Model):
name = CharField(...)
class ModelA(models.Model):
option = FK(Options)
field_1 = IntegerField()
field_2 = IntegerField()
field_3 = CharField()
field_4 = booleanField()
in forms.py
class ModelAForm(ModelForm):
class Meta:
model = ModelA
ModelAFormSet = formsets.formset_factory(ModelAForm, extra=Option.objects.count())
#but I do not understand when to use initial
in admin.py
extra_count = Options.objects.all().count()
class ModelAInline(admin.TabularInline)
model = ModelA
formset = ModelAFormSet
extra = extra_count
max_num = extra_count
but i don't understand complete, i need my admin equal this
i have 4 Option in my class Options
option field_1 field_2 field_3 field_4
--------------------------------------------------------------
option1 __ __ __ ___
option2 __ __ __ ___
option3 __ __ __ ___
option4 __ __ __ ___
i don't need add another !
I need all deployed only introduce additional data field_x (1,2,3,4)
as I can do this in the admin ??
any link? example? idea?
Cheers