First thanks for responding.
Yes there is a website www.pesprograms.com but I'm using the code in the development and it is a virtualenv. The path I provided is in fact the real path (not my 'home'). When I run collectstatic I get none of my static files - actually I'm just looking for favicon.ico. But I do want to understand what I'm doing wrong for all the static files. Question: am I suppose run collectstatic each time I change the STATIC_URL?
Johnf
On Thu, May 11, 2017 at 6:39 AM, Carl <python@nexuspro.ca> wrote:
Hi Johnf,Subject: Nginx + Gunicorn + Django ExampleFor a website using Nginx + Gunicorn + Django, try using STATIC_ROOT alongwith the following settings.If you login as user z, then usually your web project would beset up in a path like /home/z/pesweb/Note: The folder, pes_django1.11, seems out of place. Is it yourvirtual environment? Usually your virtual environment would bein a path like /home/z/pesweb/web_env/ Your specific folder setupaffects your gunicorn and nginx definitions (see below).# If your website can be browsed at http://www.pesweb.com and# your static files are browser-accessible at# http://www.pesweb.com/static/ then your STATIC URL is /static/STATIC_URL = '/static/'# If you choose to keep the out-of-place folder, pes_django1.11, then# STATIC_ROOT = '/home/z/pes_django1.11/pesweb/static/' This is not # recommended since it seems to complicate things without any advantage.## Absolute path to the directory static files should be collected to.STATIC_ROOT = '/home/z/pesweb/static/'And, your nginx definition might be like the following one:server {listen 80;# Give a blank page if browsing the IP.root /var/www/html;# Only static files need to be browser-accessible.location /static/ {root /home/z/peswebtry_files $uri $uri/ =404;}}And, your gunicorn definition might be like the following one:[Unit]Description=gunicorn-pesweb daemonAfter=network.target[Service]User=zGroup=www-dataWorkingDirectory=/home/z/pesweb ExecStart=/home/z/pesweb/web_env/bin/gunicorn --bind unix:/home/z/pesweb/pesweb. sock pesweb.wsgi:application [Install]WantedBy=multi-user.targetHope this helps!Cheers,Carl-------- Original Message --------Subject: trouble with setting static for img and cssLocal Time: May 11, 2017 8:28 AMUTC Time: May 11, 2017 12:28 PMFrom: johnf@jfcomputer.comTo: Django users <django-users@googlegroups.com> Hi folks,I have researched this issue and I know all I have to do is read thedoc's. But I can seem to get the correct path working to allow thewebsite to find the correct files in my Media,CSS and JS folders.I'm using 1.11.x and have the following setup in OS file system.I have set DEBUG = True/z/pes_django1.11/pesweb/ is where my manage.py is located - it runsjust fine.my files are in/z/pes_django1.11/pesweb/static/static/css/ - this of course is for CSS /z/pes_django1.11/pesweb/static/static/js/ -this of course is for JS /z/pes_django1.11/pesweb/static/static/img/ -this of course is for images like favicon.icoIn my settings.py file I have tried many combinations such as:STATIC_URL = '/pesweb/static/static/'STATIC_URL = '/static/static/'STATIC_URL = '/pesweb/static/'So would some kind soul please tell me what I need in STATIC_URL, andMEDIA_URL.Thanks in advance,Johnf--You received this message because you are subscribed to the Google Groups "Django users" group.To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com .To post to this group, send email to django-users@googlegroups.com.Visit this group at https://groups.google.com/group/django-users .To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4bf10da8- .e78b-147c-78dd-0d4206143ba9% 40jfcomputer.com For more options, visit https://groups.google.com/d/optout .To view this discussion on the web visit https://groups.google.com/d/--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com .
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .msgid/django-users/ .rCHl4oSoLaOBzbUogxAt29ZjbGHEYD LuM9t2ez2SvTwoUN9Iy_ r7hM3xknWkUy4HZQZN8vm8aSAZiVMr 4SVffB9wh--MLuXi8xzOw9GXIiM% 3D%40nexuspro.ca
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANDKt80eWOa0YfOVgb_z3WEtNgO3WPmO7VNsgyzEtvQdqVM-FA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment