Hi, what is the best way fill all extra data inline, my code is

model.py
ModelA(models.Model):
   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
-- 
att.
Carlos Rocha

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAM-7rO3kybHJ1OQrnHYbhSGNmuBHV%2BZBpkh1%3DhZEnGNSX8s9Gw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to