#28326: [new feature]
-------------------------------------+-------------------------------------
Reporter: Luoxzhg | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: 1.11
Severity: Normal | Resolution:
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
-------------------------------------+-------------------------------------
Description changed by Luoxzhg:
Old description:
> 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'}
> }}}
New description:
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, required=True, 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#comment:1>
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/065.0c34f89b522c57a9e95febed5c7e47c9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.