3π
β
A ModelForm
will by default include and validate all fields of the model. If you always assign the alias
value yourself in the view, then you donβt need the alias
field in the form and you can just exclude it:
class BookForm(ModelForm):
class Meta:
model = Book
fields = ('name', 'description')
# NOTE: you can also use excludes, but many consider it a bad practice
As always, Django docs can tell you more about it.
π€lqc
2π
Youβre trying to save the model without an alias first. You need to allow blank values before you can do that. The recommended approach would be using blank
:
alias = models.CharField(max_length=100, blank=True)
π€Jesse the Game
Source:stackexchange.com