#28326: [new feature]
-------------------------------------+-------------------------------------
Reporter: Luoxzhg | Owner: nobody
Type: New | Status: new
feature |
Component: Forms | Version: 1.11
Severity: Normal | Keywords: ModelForm, Meta,
Triage Stage: | initials, modelform_factory
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Now, we can specify 'widgets', 'labels', and so on in ModelForm's Meta
innerclass and modelform_factory. But We can't specify 'initials' in Meta
and modelform_factory. We must provide initial values in explicitly
defined fields or in ModelForm instantiation.
{{{
class Person(models.Model):
first = models.CharField(max_length=10)
last = models.CharField(max_length=10)
class PersonForm(forms.ModelForm):
last = forms.CharField(max_length=10, initial="Smith")
class Meta:
model = Person
fields = '__all__'
}}}
If we can specify initial values in Meta, it is easier to specify initial
values:
{{{
class PersonForm(forms.ModelForm):
class Meta:
model = Person
fields = '__all__'
initials = {'last': 'Smith'}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28326>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.8bfd175166924a9162aa16421d3f522c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.