Code

Opened 6 years ago

Closed 6 years ago

#6938 closed (fixed)

[newforms-admin] Initial form data passed from request.GET isn't handled correctly by the admin

Reported by: Matthias Pronk <django@…> Owned by: nobody
Component: contrib.admin Version: newforms-admin
Severity: Keywords: nfa, newforms, admin
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The admin interface used to pass initial data from the URL to the forms, so calling for example:

/admin/auth/user/add/?username=foo

Would result in the "username" field to be prefilled with "foo".

This is broken in recent newforms-admin because the MultiValueDict (QueryDict) is used to extend an ordinary dict in django.newforms.forms.

The way to resolve this problem is to "flatten" the MultiValueDict to an ordinary dictionary, before passing it to the ModelForm.

Thanks to brosner on #django for the help! (basically fixing it ;)

Attachments (1)

nfa_initial_get_parameters.diff (680 bytes) - added by Matthias Pronk <django@…> 6 years ago.

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by Matthias Pronk <django@…>

comment:1 Changed 6 years ago by Matthias Pronk <django@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Instead of solving this in the Admin, it would be better to fix it in the ModelForm code, see #6939

comment:2 Changed 6 years ago by brosner

  • Resolution invalid deleted
  • Status changed from closed to reopened

Reopening due to the note in #6314.

comment:3 Changed 6 years ago by brosner

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:4 Changed 6 years ago by brosner

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [7434]) newforms-admin: Fixed #6938 -- request.GET is now coerced into a dict before being passed as initial data in ModelAdmin.add_view. Thanks Matthias Pronk.

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.