Open
Description
Hi!
I have these models:
from django.db import models
from polymorphic.models import PolymorphicModel
class Author(models.Model):
pass
class Book(PolymorphicModel):
author = models.ForeignKey(Author, on_delete=models.CASCADE)
class SpecialBook(Book):
pass
I want to make a formset to edit special books of a given author:
from django import forms
from polymorphic.formsets import polymorphic_modelformset_factory, PolymorphicFormSetChild
class SpecialBookForm(forms.ModelForm):
class Meta:
exclude = ("author",)
SpecialBookFormSet = polymorphic_modelformset_factory(Book, formset_children=(
PolymorphicFormSetChild(SpecialBook, form=SpecialBookForm),
))
By doing so, the field author
is not excluded. Indeed, due to this line, exclude
is not None
when passed to modelform_factory()
here then form.Meta.exclude
is overridden here.
What's the point of self.exclude = exclude or ()
here?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels