Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
# models.py
class Model(models.Model):
fio = models.CharField(max_length=255)
# forms.py
class Form(forms.ModelForm):
first_name = forms.CharField()
middle_name = forms.CharField()
last_name = forms.CharField()
def clean(self):
self.instance.fio = '{first_name} {middle_name} {last_name}'.format(**self.cleaned_data)
return self.cleaned_data
class Meta:
model = Model
fields = ['first_name', 'last_name', 'middle_name']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question