Code

Opened 7 years ago

Closed 7 years ago

#4019 closed (duplicate)

Use default-value of model-fields as initial-value for newforms-fields

Reported by: David Danier <goliath.mailinglist@…> Owned by: adrian
Component: Forms Version: master
Severity: Keywords: model default newforms field initial
Cc: brosner@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I think using the default-value of a model-field as the initial value of the newsforms equivalent could be useful. So I added setting defaultsinitial? in the formfield()-method of every model-fields.
As I'm not really using this the code is only tested a little, but looks working.

I did not put the code into django.newforms.models.* as I think this should be handled inside the field itself (like all other values). But perhaps some solution could be found to avoid code duplication (DRY).

Attachments (1)

django-use-model-default-as-newforms-initial.diff (6.3 KB) - added by David Danier <goliath.mailinglist@…> 7 years ago.

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by David Danier <goliath.mailinglist@…>

comment:1 Changed 7 years ago by brosner <brosner@…>

  • Cc brosner@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by Brian Rosner <brosner@…>

  • Resolution set to duplicate
  • Status changed from new to closed

I put myself on the CC list since this does effect me slightly, but I discovered this is a duplicate. I am marking this a duplicate of #899.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.