#26248: Make current WSGI request instance available in forms.ModelForm 
instances.
--------------------------------+--------------------------------------
     Reporter:  Dmitri-Sintsov  |                    Owner:  nobody
         Type:  New feature     |                   Status:  closed
    Component:  Forms           |                  Version:  master
     Severity:  Normal          |               Resolution:  wontfix
     Keywords:                  |             Triage Stage:  Unreviewed
    Has patch:  0               |      Needs documentation:  0
  Needs tests:  0               |  Patch needs improvement:  0
Easy pickings:  0               |                    UI/UX:  0
--------------------------------+--------------------------------------

Comment (by Dmitri-Sintsov):

 I have "orthogonal" kwargs in urls.py request to views mapping throughout
 the code with the same url regex key names: 'project_id', 'profile_id' .
 Then I implemented my own context middleware which process_view() checks
 for 'project_id' / 'profile_id' of current view kwargs. It also has the
 whole "business logic" context class, which tries to load Project /
 Profile models from DB by these PK's, then checks current user access
 permissions to these model instances, performs additional steps when
 necessary.

 That saves a lot of repetitive boilerplate code in views where I get ready
 loaded and already checked self.request.context with appropriate project
 and /or user profile models, instead of loading them over and over. The
 trouble is, that sometimes I need to access that self.request.context
 instance from ModelForm.clean() method and these forms are used not only
 in views and CBV's where it's easy to add self.request to instance of
 ModelForm, but also in django.admin, including third-party nested inline
 admin.

 I will probably have to implement per thread request context storage as
 you've suggested. Because anyway I use stable 1.8 LTS, not current working
 master (nested inline admin module has some troubles with newer Django
 versions).

--
Ticket URL: <https://code.djangoproject.com/ticket/26248#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.86d1d2ba8df50ffa4e9ec4c3e0772f6f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to