I want to exclude, programatically, a field in my form. Currently I have this:
class RandomForm(BaseForm):
def __init__(self, *args, **kwargs):
# This doesn't work
if kwargs["instance"] is None:
self._meta.exclude = ("active",)
super(ServiceForm, self).__init__(*args, **kwargs)
# This doesn't work either
if kwargs["instance"] is None:
self._meta.exclude = ("active",)
class Meta:
model = models.Service
fields = (...some fields...)
How can I exclude the active
field only when a new model is being created?
self._meta.exclude = ("active",)
gets executed? Or are you getting errors? – MaestosoRandomForm
really calling the super method fromServiceForm
? – Maestoso