Thanks guys - that worked!!!!!!!!!
I'm going to call it black magic - because to be truthful I don't
understand how it really works. If anyone has a better link than
Django's on static files that explains what is really happening - it
would be very helpful.
Johnf
On 04/22/2015 04:57 PM, Mike Dewhirst wrote:
> On 23/04/2015 9:35 AM, john wrote:
>> Hi,
>> I have created a website that works well under "runserver". But when I
>> use nginx and uwsgi the basic website comes up but it is missing the
>> static file information. I have run "manage.py collectstatic" but still
>> no static files are used.
>>
>> Reading the Django doc's tells me that I need the webserver to serve the
>> static files. Ok I think I can do that (maybe). But I don't understand
>> completely. In my templates I have links like:
>> <link href = "{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
>>
>> How does the nginx server understand to provide the css file for my html
>> page from the code above?
>>
>> I read that I can add a 'location' in the nginx config file but don't
>> understand how nginx would understand to provide it when my template is
>> called.
>
> You probably want three locations ... here are mine:
>
> location /static/ {
> root /home/mike/envs/pq5/project;
> access_log off;
> log_not_found off;
> }
>
> location /robots.txt {
> root /home/mike/envs/pq5/project/static;
> access_log off;
> log_not_found off;
> }
>
> location /favicon.ico {
> root /home/mike/envs/pq5/project/static/img;
> access_log off;
> log_not_found off;
>
> So whenever a client browser requests something prefixed by /static/
> nginx sees that and substitutes the value of "root". Therefore,
> collectstatic has to put your css files exactly where your template
> says to look for them.
>
> Collectstatic knows exactly where by checking the value in
> settings.STATIC_ROOT
>
> hth
>
> mike
>
>>
>> Thanks for the help 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/55383875.6020900%40jfcomputer.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment