Opened 18 years ago
Closed 18 years ago
#3247 closed defect (fixed)
Disable field creation in forms for hidden model fields
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | normal | Keywords: | |
Cc: | philipp.keller@…, bs1984@…, christian@…, yatiohi@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
django.newforms.models.form_for_model()
should not create a form field for model fields declared with editable=False
.
Attachments (3)
Change History (18)
by , 18 years ago
Attachment: | disable_formfield_for_hidden_fields.diff added |
---|
by , 18 years ago
Attachment: | disable_formfield_for_hidden_fields_1.diff added |
---|
comment:1 by , 18 years ago
I'm not sure whether this should be the correct behavior. Is editable=False
intended to be only for the admin site, or does it mean that field shouldn't be edited by *any* form?
comment:2 by , 18 years ago
Summary: | [patch] Disable field creation in forms for hidden model fields → [patch] [design-q] Disable field creation in forms for hidden model fields |
---|
I'm putting [design-q]
in the subject to designate "a design decision needs to be made here." It's just as a little experiment to see whether this extra tagging is useful.
comment:3 by , 18 years ago
Summary: | [patch] [design-q] Disable field creation in forms for hidden model fields → [design-q] [patch] Disable field creation in forms for hidden model fields |
---|
Changed summary to put [design-q]
first, to be consistent.
comment:4 by , 18 years ago
I've read the following
http://www.b-list.org/weblog/2006/11/02/django-tips-auto-populated-fields:
The created and updated fields now have editable=False. This means that they will never show up in an automatic manipulator or in the admin. They’re still required, they just won’t be displayed anywhere.
So I supposed this behaviour is meant for newforms too and just never got implemented.
But for the discussion: shouldn't be the other way round? I'd expect a editable=false field not to appear in a automatic generated form. I'd expect the form field list for admin in a configuration in the admin subclass.
comment:5 by , 18 years ago
Summary: | [design-q] [patch] Disable field creation in forms for hidden model fields → Disable field creation in forms for hidden model fields |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
comment:6 by , 18 years ago
follow-up: 8 comment:7 by , 18 years ago
Triage Stage: | Design decision needed → Accepted |
---|
Since the discussion didn't bring up any objections against this solution, I switch triage to "accepted"
comment:8 by , 18 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
Patch needs improvement: | set |
Hi Philip, you're welcome to help out and triage tickets! But, please, go through everything as described in triage docs.
The patch in this ticket does not apply anymore (so I can't test it). Can you please update it? Tests and docs will be needed before it can be checked id, too.
by , 18 years ago
Attachment: | disable_formfield_for_hidden_fields_trunk.diff added |
---|
Patch matching 4451, included patch as well
comment:9 by , 18 years ago
Needs tests: | unset |
---|---|
Owner: | changed from | to
Patch needs improvement: | unset |
Status: | new → assigned |
Version: | → SVN |
Hi Michael, sorry, I forgot to add needs_docs and needs_tests to this ticket.
I did a new patch that matches the current trunk. I've also included a test in model_forms/models.py
It's quite hard to add documentation since the whole models.py isn't documented yet. Some time ago I wrote a tutorial on my blog (http://code.pui.ch/2007/01/07/using-djangos-newforms/) that could serve as a start point for adding documentation for the form_for_model and form_for_instance functions.
What do you think?
comment:10 by , 18 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
Thanks for the tests. The assigned field is to match tickets to core developers, please leave it as it is unless you know exactly what you're doing ;-)
comment:11 by , 18 years ago
Cc: | added |
---|
comment:12 by , 18 years ago
Cc: | added |
---|
comment:13 by , 18 years ago
Cc: | added |
---|
I have tested the patch (disable_formfield_for_hidden_fields_trunk.diff
), and it seems to work fine.
comment:14 by , 18 years ago
Cc: | added |
---|
comment:15 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Patch from the root directory of django distribution, please ignore the previous patch.