I want to update the Meta.fields
dynamically. Is it possible to do it from the Form constructor? I tried the following but year
doesn't show up during the form generation. Only name
and title
are displayed.
class Author(models.Model):
name = ...
title = ...
year = ...
class PartialAuthorForm(ModelForm):
class Meta:
model = Author
fields = ('name', 'title')
def __init__(self, *args, **kwargs):
self.Meta.fields += ('year',)