Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
323 views
in Technique[技术] by (71.8m points)

django - adding new Inline form using smart-selects nothing happens

I have a code below.

class Evaluation(models.Model):
    person = models.ForeignKey(Person, on_delete=models.CASCADE)


class EvaluationDisability(models.Model):
    disability = models.ForeignKey(Disability, on_delete=models.CASCADE)
    disability_details = ChainedManyToManyField(
        DisabiltiyDetail,
        horizontal=True,
        chained_field="disability",
        chained_model_field="disability")
    # evaluation = models.ManyToManyField(Evaluation,blank=False)
    evaluation = models.ForeignKey(Evaluation, on_delete=models.CASCADE)
class EvaluationDisabilityForm(forms.ModelForm):
    model = EvaluationDisability

class EvaluationDisabilityInline(admin.TabularInline):
    model = EvaluationDisability
    form = EvaluationDisabilityForm
    extra = 1
    # autocomplete_fields = ['disability_details']


@admin.register(Evaluation)
class EvaluationAdmin(admin.ModelAdmin):
    model = Evaluation
    inlines = [EvaluationDisabilityInline]

right there is says extra=1

So on the admin page the smart-selects is workin fine just for only 1 row. But adding new row.. smart-selects not working anymore.

Same thing if i change the extra to any number. for example extra=5. smart-selects works for the first 5 rows but adding a new one will do nothing.

Please help been looking for the resolution on this for weeks now

question from:https://stackoverflow.com/questions/65645939/django-adding-new-inline-form-using-smart-selects-nothing-happens

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...