Re: Need to get user_id outside of a view

2017-01-29 Thread Aron Podrigal
I've had similar use cases where I needed access to the request in a number of places. I've come to the conclusion that any code that is expected to operate under wsgi (and only under wsgi, and not via management commands) to use thread locals. see https://github.com/nebstrebor/django-threadlocals

Re: Need to get user_id outside of a view

2017-01-29 Thread Victor Porton
Probably a good way to solve this problem is to add `request` (with default `None`) argument to `Model.save` method, which could then be passed to the storage used for file fields. Let us discuss if this is a good solution or can we invent something better. On Sunday, January 29, 2017 at 8:12:1

Need to get user_id outside of a view

2017-01-29 Thread Victor Porton
See also https://code.djangoproject.com/ticket/27786 I attempt to make file storage behavior dependent on the current user. (In fact, I attempted to store the ID of the uploader of a given file into the database, so that other users could not list or delete this file. Also I tried to store the fi