django-currentuser | Conveniently store reference to request user | Caching library
kandi X-RAY | django-currentuser Summary
kandi X-RAY | django-currentuser Summary
Conveniently store reference to request user on thread/db level.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Write the test suite
- Return a matrix of tox code
- Return the test command to run
- Setup python
- Parse tox output
- Extracts the list of installed python versions
django-currentuser Key Features
django-currentuser Examples and Code Snippets
Community Discussions
Trending Discussions on django-currentuser
QUESTION
I have a problem and I will do the best to explain it, to see if you can help me out.
CONTEXT
I have a system running in a test server, which is set up like a production environment in order to test my code before merging to master and give the go to the production server provider of my client to update the code. This means it runs in DEBUG = False
. All good, all perfect for months.
I decided to activate the ManifestStaticFilesStorage
setting in order to have a hash number added in my static files, I've used it before and it's a good way to break cache rules when updating files (like CSS rules that refuse to load). There is an issue with cache that may be solvable messing around with the server but that's not an option in this case.
Everything went smoothly:
- No issues in collectstatic other than a few missing static files (already solved)
- Static files loaded perfectly
BUT...
THE PROBLEM
This system manages content (images, audio files and custom fonts). When I activated the ManifestStaticFilesStorage
setting, all uploaded files started to throw 404 errors (and some occasional 500 error) in the server access log. Meaning, they look like this:
You can see the broken image icon but you can also see the background colores of each square (color which is injected by JS because it can be customized in the custom CMS). These images are uploaded in the CMS and they live in the media folder configured in the settings file.
Of course, if I go to DEBUG = True
, everything gets fixed (come on! -.-). I went and recreated production enviroment in local, same issue: DEBUG = False
bad, DEBUG = True
works
THOUGHTS
- 404 means the file is not there. Guess what? it's there, they all are
- The occasional 500 means permissions. Well, I haven't changed the permissions. Also, permissiones where the same. Also, I'm using WebFaction, it handles all that for me
- Console in browser says network error. In the Network tab it doesn't even show the 404 errors or the few 500 that may appear
- Broken DB? Nope. Besides, if it were broken,
DEBUG = True
would fail - Apache error log? Nothing to show for. The access log shows the access errors, meaning errors on file that are correctly placed
So, I ran out of ideas. Maybe someone out there has the answer, I hope so. I will still be trying to solve it but I can use the help, please.
RELEVANT CODE
storage.py
...ANSWER
Answered 2020-May-20 at 20:47Well, after hitting my head to the wall a lot, a good night sleep and fresh ideas, I found the problem. It was the silliest thing ever, as usual.
If you can see in the settings.py, the MEDIA_URL
is set to /media/
. Normally, this wouldn't be a problem in an Apache server but in WebFaction, it turned out to be the culprit of my headache.
For those who don't know, WebFaction obliges you to create apps for everything: Python env, PHP env, Static env, WordPress, Joomla, etc. By creating an app, you have to assing a unique path inside the Website definition, which is a set of apps running under a given domain, so all apps have paths under the same domain and you don't have to modify (in most cases) the httpd.conf
file.
I have an app for the Django code and another app for the static files, under the domain static/
. In the local_settings.py
, you can see that the MEDIA_ROOT
is inside this static path.
In a regular Apache deploy, you just assign the /media/
URL to the path and that's it. In WebFaction, given that there is no static app for using the media/
, the MEDIA_URL
variable has to have static/media
as assigned value when switching to DEBUG = False
.
Just to remember: DEBUG = False
make Django stop serving the static files and leave that entirely to the server where is deployed. So, in DEBUG = True
, it didn't matter which was the media URL because Django is smart enough to see past that. But when I made the switch to DEBUG = False
, it naturally failed.
Silly me, but well, this is how we learn.
Regards.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install django-currentuser
You can use django-currentuser like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page