14👍
Use
Finished = models.IntegerField('Finished percentage', blank=True, null=True)
Read https://docs.djangoproject.com/en/1.4/ref/models/fields/#blank:
null is purely database-related, whereas blank is validation-related.
You might have defined the field without null=True
first. Changing that in the code now won’t change the initial layout of the database. Use South for database migrations or change the database manually.
6👍
On a form you could set required=False
on the field:
Finished = forms.IntegerField(required=False)
Or to avoid redefining the field on a ModelForm,
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
self.fields['Finished'].required = False
#self.fields['Finished'].empty_label = 'Nothing' #optionally change the name
👤CJ4
- Overwriting a block within an `include`d template from an extended template
- Can't debug Django unit tests within Visual Studio Code
- Custom unique_together key name
2👍
Maybe a default value is needed
finished = models.IntegerField(default=None,blank=True, null=True)
Source:stackexchange.com