Opened 5 years ago
Closed 5 years ago
#31438 closed Bug (invalid)
Current user in form.
Reported by: | marc-dms | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 3.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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
Change History (1)
comment:1 by , 5 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Summary: | Current user in form → Current user in form. |
Note:
See TracTickets
for help on using tickets.
I don't see such recommendation anywhere in the docs. Moreover you cannot add a hidden field if an user ID is sensitive for you. It's a support question and Trac is not a support channel.
Closing per TicketClosingReasons/UseSupportChannels.