[Django] #29137: ModelForm, Generic Views and Generic Edit Views Custom Layout Simplification

25 views
Skip to first unread message

Django

unread,
Feb 16, 2018, 12:28:35 AM2/16/18
to django-...@googlegroups.com
#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.

Django

unread,
Feb 16, 2018, 10:27:38 AM2/16/18
to django-...@googlegroups.com
#29137: ModelForm, Generic Views and Generic Edit Views Custom Layout
Simplification
-------------------------------------+-------------------------------------
Reporter: Spleeding1 | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Forms | Version: 2.0
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => wontfix


Comment:

The ability to define fieldsets on forms is a duplicate of #6630 (closed
as wontfix).

Regarding automatically changing input boxes size based on `max_length` --
that would be a rather disruptive change and not something that everyone
would want. You could write a mixin for your forms to accomplish that.

--
Ticket URL: <https://code.djangoproject.com/ticket/29137#comment:1>

Reply all
Reply to author
Forward
0 new messages