Django stopped finding application static files - django

I have a Django 1.9.8 app that's working most of the times. For some reason, Django stopped service application static files, including those of the build-in admin application.
Running collectstatic only looks for files in my STATICFILES_DIR, as does findstatic.
I do have django.contrib.staticfiles in my INSTALLED_APPS, and yet - Django does not look for its apps' static files.
I'm stumped and don't even know where to look next.

Turns out the problem was fixed by deleting the virtual environment and creating it again (without upgrading anything).
Hope this saves someone some time in the future.

Related

Folders statics not found in server google - Django

Django cannot find the static files on the google server, the
python manage.py collectstatic
command has already been used with the settings.py configured.
To solve this problem I followed several tutorials that showed us how to deploy static files, including the documentation itself. However, none got results. It is worth mentioning that this same code and configuration worked in the homolog version of the system.

Windows IIS 10 will not serve static files from Anaconda / Django 2.2 . . . How can I fix this?

The website displays to localhost without css, js, or images.
I setup Windows IIS according to this blog including the final section about static files. The methods outlined are similar to answers from this question, this question, this blog, and this youtube video on how to serve static files from django with IIS.
UPDATE: The problem may be coming from my virtual environment. This project was developed with Anaconda. When I followed the listed tutorials I simply used the paths to my conda venv and didn't think anything of it since the localhost loaded without errors. At the time python was only present on my machine in the anaconda environment, so if manage.py was able to execute and database data was accessed and displayed(without css/js) then I presumed this was not an issue. I am currently trying to interpret this blog on how to setup Anaconda for IIS 8.5 to see if I need to make additional changes to IIS 10. I have not had any luck using web.config files and have had to accomplish the same goals through IIS manager. Jalpa Panchal's comment lead me to investigate the environment.
Any ideas on what additional changes need to be made for IIS 10 to interpret an Anaconda(conda 4.8.3) developed django application?
ORIGINAL POST:
Django settings:
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, 'static') # tested in shell, it is where I expect at the same level as manage.py
The directory "static" was created with manage.py collectstatic in the expected STATIC_ROOT location with all of the static files contained
IIS Manager:
The static directory was then added as a virtual directory:
Then I removed the django handler I created from the static directory's handler mappings:
I unlocked the handlers at the root:
The django application did display properly, with static files, when I tried using Wampserver w/ Apache and mod_wsgi. Unfortunately, it appears windows IIS will be the better solution for other unrelated reasons. Not too mention Wampserver is a development server, not a production server.
I defined a path for the environment variable WSGI_LOG, the logs generated have no errors. Just states wfastcgi.py was initialized and will restart when there are changes to the files in my project
What else can I be missing that would prevent my static files from being processed?

Docker-compose django nginx doesnt find static files

I'm trying to dockerize my application and i'm almost done. The only issue I have is that nginx doesn't find my static files. I've searched all over the web, but I havent found a solution yet.
I made a volume that's shared between the Django application and the Nginx server, and in my settings.py I pointed the settings to that, but no luck.
I'm not sure how many of the files you need to inspect, so I uploaded the whole project to Github.
https://github.com/temp3020102/django_project
When the image has been built and you navigate to http://localhost/admin one can see that the CSS is missing.
I'm aware that posting the secret_key and such to the internet is not a good idea, and i'm of course changing that once I have a fix for the issue. It's just there for the sake of your convenience.
You are referring to /home/app/web/staticfiles/ for static files in nginx
But in code it is located in /home/app/web/static folder
rename the folder static to static_volume

Django restframework bootstrap static files

I have a regular django site, with djangorestframework (v2.3.14) serving restful api under "/api". On local box everything works fine (mac / mavericks), on remote box (Ubuntu 12) the API browser comes up but all the bootstrap stuff is missing (the page looks like it's out of 1992 prototype instead of pretty bootstrap theme i see locally).
All the pip dependencies have been upgraded and are identical. Locally running site through PyCharm, remotely it is running on WSGI.
What can I check to see what the issue is and resolve it??
I suppose that under PyCharm on your local machine you are running the development server, which serves static files directly from your apps and projects internal locations.
After every deployment into production (your WSGI server) you need to collect all static files to a single place, your STATIC_ROOT. This is a job for the django management command collectstatic, see Django docs here.
The command may look like this:
# Executing collectstatic (organize static files)
python /path/to/your/project/manage.py collectstatic --noinput
For further details you may also read Django cannot find static files. Need a second pair of eyes, I'm going crazy.
If this question doesn't help, you can quicly fix it making a link under your proyect's static folder
ln -s /your_env_folder/lib/pythonX.X/site-packages/rest_framework/static/rest_framework rest_framework

Django: STATIC_* and MEDIA_* all identical, but app still runs in production

I'm currently working on a Django 1.3 app where both MEDIA_ROOT and STATIC_ROOT are identical, and MEDIA_URL and STATIC_URL are identical.
This (somehow) runs on the production server, but locally when I call manage.py runserver I get an ImproperlyConfigured exception and can only run the application when I override the settings so that MEDIA_* is different from STATIC_* (DEBUG=False just gives a 500). This is what I would expect to happen (as per documentation), and so I don't understand how they can get it working in Production.
The original developer of the application has moved on so I can't ask any questions as how they've managed to get this to work. Is there a known method of circumventing Django's static and media file separation?
Not a great answer as it's so specific, but the answer was that they just never run the application with DEBUG=True (runserver will run happily with DEBUG=False and incorrect MEDIA_* and STATIC_* settings). There was no silver bullet, the application appears to be debugged using the error log created by mod_wsgi (no logging in place). I assume that this also how the development environment was set up.
The application is also notable for being run whilst not being on the PYTHONPATH, and having all of its apps in a separate folder in another part of the filesystem. This was discovered when adding a new application to the folder containing manage.py and having import errors for the new application. I think this was so that multiple django installations could use the same set of apps.
Thanks to Yuji for his help .