Django

Code

Ticket #3247 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

Disable field creation in forms for hidden model fields

Reported by: mssnlayam@yahoo.com Assigned to: adrian
Milestone: Component: Forms
Version: SVN Keywords:
Cc: philipp.keller@gmail.com, bs1984@gmail.com, christian@gmta.info, yatiohi@ideopolis.gr Triage Stage: Accepted
Has patch: 1 Needs documentation: 1
Needs tests: 0 Patch needs improvement: 0

Description

django.newforms.models.form_for_model() should not create a form field for model fields declared with editable=False .

Attachments

disable_formfield_for_hidden_fields.diff (1.7 kB) - added by mssnlayam@yahoo.com on 01/07/07 16:21:17.
disable_formfield_for_hidden_fields_1.diff (1.8 kB) - added by mssnlayam@yahoo.com on 01/07/07 16:23:15.
Patch from the root directory of django distribution, please ignore the previous patch.
disable_formfield_for_hidden_fields_trunk.diff (2.9 kB) - added by Philipp Keller <philipp.keller@gmail.com> on 01/30/07 05:50:44.
Patch matching 4451, included patch as well

Change History

01/07/07 16:21:17 changed by mssnlayam@yahoo.com

  • attachment disable_formfield_for_hidden_fields.diff added.

01/07/07 16:23:15 changed by mssnlayam@yahoo.com

  • attachment disable_formfield_for_hidden_fields_1.diff added.

Patch from the root directory of django distribution, please ignore the previous patch.

01/12/07 23:03:27 changed by adrian

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?

01/12/07 23:05:08 changed by adrian

  • summary changed from [patch] Disable field creation in forms for hidden model fields to [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.

01/12/07 23:30:46 changed by adrian

  • summary changed from [patch] [design-q] Disable field creation in forms for hidden model fields to [design-q] [patch] Disable field creation in forms for hidden model fields.

Changed summary to put [design-q] first, to be consistent.

01/13/07 06:09:19 changed by Philipp Keller <philipp.keller@gmail.com>

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.

01/17/07 16:44:28 changed by adrian

  • summary changed from [design-q] [patch] Disable field creation in forms for hidden model fields to Disable field creation in forms for hidden model fields.
  • stage changed from Unreviewed to Design decision needed.

01/20/07 17:05:49 changed by Simon G. <dev@simon.net.nz>

(follow-up: ↓ 8 ) 01/25/07 01:26:39 changed by Philipp Keller <philipp.keller@gmail.com>

  • stage changed from Design decision needed to Accepted.

Since the discussion didn't bring up any objections against this solution, I switch triage to "accepted"

(in reply to: ↑ 7 ) 01/25/07 06:12:21 changed by Michael Radziej <mir@noris.de>

  • needs_better_patch set to 1.
  • needs_tests set to 1.
  • needs_docs set to 1.

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.

01/30/07 05:50:44 changed by Philipp Keller <philipp.keller@gmail.com>

  • attachment disable_formfield_for_hidden_fields_trunk.diff added.

Patch matching 4451, included patch as well

01/30/07 05:55:40 changed by Philipp Keller <philipp.keller@gmail.com>

  • owner changed from adrian to anonymous.
  • needs_better_patch deleted.
  • version set to SVN.
  • status changed from new to assigned.
  • needs_tests deleted.

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?

01/30/07 06:35:31 changed by mir@noris.de

  • owner changed from anonymous to adrian.
  • status changed from assigned to 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 ;-)

01/30/07 08:31:18 changed by Philipp Keller <philipp.keller@gmail.com>

  • cc set to philipp.keller@gmail.com.

01/30/07 12:24:24 changed by anonymous

  • cc changed from philipp.keller@gmail.com to philipp.keller@gmail.com, bs1984@gmail.com.

02/15/07 13:03:02 changed by christian@gmta.info

  • cc changed from philipp.keller@gmail.com, bs1984@gmail.com to philipp.keller@gmail.com, bs1984@gmail.com, christian@gmta.info.

I have tested the patch (disable_formfield_for_hidden_fields_trunk.diff), and it seems to work fine.

02/19/07 15:21:07 changed by anonymous

  • cc changed from philipp.keller@gmail.com, bs1984@gmail.com, christian@gmta.info to philipp.keller@gmail.com, bs1984@gmail.com, christian@gmta.info, yatiohi@ideopolis.gr.

02/19/07 20:59:16 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [4548]) Fixed #3247 -- newforms form_for_model() and form_for_instance() no longer create form fields for database fields with editable=False. Thanks for the patch, mssnlayam@yahoo.com and Philipp Keller


Add/Change #3247 (Disable field creation in forms for hidden model fields)




Change Properties
Action