#29137: ModelForm, Generic Views and Generic Edit Views Custom Layout
Simplification
------------------------------------------------+------------------------
Reporter: Spleeding1 | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Forms | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
I'm trying to make a customer form linked to a database(ModelForm) that on
the screen would look like:
{{{
<fieldset name> Customer Information </fieldset name>(not actual html)
First_Name Last_Name MI
Address_1
Address_2
City State Zip_Code
}}}
These forms currently give you these html options: as "paragraph", as
"list", as "table", which don't fit my layout. The text input boxes are
also all the same size. To manually render the template requires a lot of
html coding, adding labels etc.
The (admin.ModelAdmin) "fieldsets" already does this in the admin site. Is
there a way of implementing this in these views?
Some options to consider: (ModelForm example)
{{{
class CustomerForm(ModelForm):
class Meta:
model = Customer
fieldsets = [
('Name and Address', {'fields' : [ ('first_name', 'last_name',
'mi'),
'address_1',
'address_2',
('city', 'state', 'zip_code')
]
}
)
('Phone and Email', {'fields' : [ #(etc...)
}}}
And be able to customize:
" 'classes' : " or you could give it a css or javascript class and put
it in your static file:
{{{
('Name and Address', {'fields' ('class' : ['name_field'], 'classes' :
['collapse'] ): [ ('first_name', (etc...)
}}}
And finally, make text input boxes the same "size" as the "max_length="
setting for the form or model.
Maybe there is an easy way to do all of this and I just couldn't find it
in the documentation. If so, please let me know, and sorry.
--
Ticket URL: <https://code.djangoproject.com/ticket/29137>
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/053.e235eaa03ca06d08cf2535b3a59a91dd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.