azure static files missing/ wrong MIME - django

Django website deployed to Azure (F1 - free subscription) Linux, all static files are missing/ not rendered. Even the files from admin which are not changed. Locally works fine, I've googled around tried to upload without VS code etc. still does not work.
Source code of app - https://github.com/Azure-Samples/python-docs-hello-django
Tutorial - https://learn.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=bash&pivots=python-framework-django
Deployed via Azure CLI, any pointers I would gladly take.
P.S. Templates dir and HTML files are fine/ loaded correctly, images from static are also missing.

Solution to my problem was new install + whitenoise, requirements.txt for Azure, following the approach and settings file in the video below:
https://www.youtube.com/watch?v=D6Wyk9q2JM0&list=RDCMUCsMica-v34Irf9KVTh6xx-g&start_radio=1&t=302s
Github project - https://github.com/microsoft/beginners-django

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.

I have deployed my Django App on Microsoft Azure and Static files are not displaying, only html

I've deployed a Django app on Azure and run it, everything was working fine css, images, js. After i run Gunicorn to automate the site then Only skeleton HTML displayed, css, images and js disappeared.
this is the Erro:
/home/honest/venv/lib/python3.6/site-packages/django/core/handlers/base.py:58: FutureWarning: TemplateForDeviceMiddleware is deprecated. Please remove it from your middleware settings.
mw_instance = mw_class()
/home/honest/venv/lib/python3.6/site-packages/django/core/handlers/base.py:58: FutureWarning: TemplateForHostMiddleware is deprecated. Please upgrade to the template loader.
Not Found: /static/images/sample/slider/img7.png/
May i know if i need to configure WhiteNoise for gunicorn on Azure?
Do i Need to edit my HTML templates to point to static folder in Azure?
I tried some of the solutions i saw here like setting DEBURG to True set path for static files in Settings.py but it couldn't help.
I will be glad receiving a step by step solution to this.
Thanks for the assistence.

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

How to use Weasyprint with AWS Lambda? (Django & Zappa)

I have a simple Django app which has been pushed to AWS Lambda using Zappa.
This process has worked properly, with one exception : cannot load library 'pango-1.0': pango-1.0: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called 'pango-1.0'
I'm using Weasyprint to generate PDF files. Weasyprint needs Cairo and Pango.
I don't know how to get Pango to work on my AWS Lambda install.
What should I do to make it work ?
So, after asking around in multiple locations, I found out that I needed the static versions of all the libraries required by Weasyprint, and that I needed to push these in my zappa package.
Luckily, a github user has uploaded a working repo of the static requirements : https://github.com/Prasengupta/weasyprint_for_awslambda
So all I had to do was download it and extract all the folders at the root of my django app (the folders must be at the same level as the zappa_settings.json file).
I then just had to do a zappa update command to upload all these files to my AWS Lambda install, and it worked!
My Django app is now full of weird directories, but at least the whole thing works.

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