allow blank form input, use clean func to keep old val

This commit is contained in:
james1293 2019-07-24 15:10:26 -04:00
parent 242067e46c
commit 3da5bf052e
3 changed files with 26 additions and 1 deletions

View file

@ -49,6 +49,11 @@ class AddEditTaskForm(ModelForm):
note = forms.CharField(widget=forms.Textarea(), required=False)
def clean_created_by(self):
"""Keep the existing created_by regardless of anything coming from the submitted form.
If creating a new task, then created_by will be None, but we set it before saving."""
return self.instance.created_by
class Meta:
model = Task
exclude = []