#31438: Current user in form
-----------------------------------------+------------------------
               Reporter:  marc-dms       |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  Documentation  |        Version:  3.0
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 Hi,

 Thanks for your contributions. On one hand, the following suggestion from
 [https://docs.djangoproject.com/en/3.0/topics/class-based-views/generic-
 editing/] to store the current user in a form **impairs form level
 validation such as unique-together**.
 {{{
 form.instance.created_by = self.request.user
 }}}

 On the other hand hiding the field and using the following code **exposes
 the id and opens a backdoor to malicious code that would modify the hidden
 field**.
 {{{
 def get_initial(self): return { 'created_by': self.request.user }
 }}}

 Could the doc rather suggest a solution that would solve both issues?

 Best,

 -- M

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31438>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.fc91bd708799f82134b0a0f5a5096f42%40djangoproject.com.

Reply via email to