name = charfield(...)
CHOICE_OPTION = ((1,'One'),(2,'Two'),(3, 'Three')
ModelB(models.Model):
fk(ModelA)
option = integerfield(choice=CHOICE_OPTION)
field1 = boolfield()
field2 = boolfield()
field3 = boolfield()
forms.py
class ModelBInlineAdminForm(forms.ModelForm):
class Meta:
model = ModelB
fields = '__all__'
def __init__(self, *args, **kwargs):
super(ModelBInlineAdminForm, self).__init__(*args, **kwargs)
self.initial = {
'option': 1,
'option': 2,
'option': 3,
}
admin.py
class InlineModelB(admin.TabularInline):
form = ModelBInlineAdminForm
model = ModelB
extra = 3
max_num = 3
class ModelAAdmin(admin.ModelAdmin):
inlines = [InlineModelB]
but the result is not as expected, I repeat only the last option,
i need One, Two, Three
my inline look like this
option | field1 | field2 | field3
Three | [] | [] | []
Three | [] | [] | []
Three | [] | [] | []
i use django 1.11.18, python3.6
What is the best way to do this, some link to read to guide me in the right way
Cheers
--