Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#8494 closed (wontfix)

Instantiating ModelForm with request as kwargin ModelAdmin

Reported by: sorl Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

May I propose instantiating the ModelForm with request as kwarg in add_view, change_view in ModelAdmin class. This would allow the form, fields to be customized and validated on a per user basis.

-form = ModelForm(request.POST, request.FILES)
+form = ModelForm(request.POST, request.FILES, request=request)

Perhaps also the FormSet

Change History (3)

comment:1 Changed 8 years ago by Malcolm Tredinnick

milestone: 1.0post-1.0

This is a feature request. No way is it 1.0 material.

comment:2 Changed 8 years ago by James Bennett

Resolution: wontfix
Status: newclosed

ModelAdmin.get_form() receives the request (and, for object-level change requests, also the object) and is expected to return a Form subclass to use, and overriding that is how you should do per-user or per-request form tweaks.

comment:3 Changed 8 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top