Django how to make form fields optional
django, python
Solution
Presuming you want to make `last_name` optional, you can use the `blank` attribute:
class Student(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=40, blank=True)
email = models.EmailField()
Note that on `CharField` and `TextField`, you probably don't want to set `null` (see this answer for a discussion as to why), but on other field types, you'll need to, or you'll be unable to save instances where optional values are omitted.
Problem
In django how to make form field optional ? my model, ``` class Student(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=40) email = models.EmailField() ```