Thanks that helps with the nginx configure file. But what I don't
understand is how the template tells nginx what to serve? There has to
be some sort of black magic here! As I understand the process - the
client asks for a page - django routes via urls - it finds the template
and processes it - uses the static file location - django grabs the
static file and sends it. How does Nginx know what to do?
Being a newbie - I'd like to understand why I'm adding a 'locaiton' and
how the nginx becomes aware that it is needed.
On 04/22/2015 04:47 PM, Lachlan Musicman wrote:
> Oh my aching head and static files.
>
> STATIC_URL points to the namespace that the files will be served from:
> eg mydomain.com/static
> To set this up, in nginx/apache you need a stanza that looks like:
>
> location /static {
> alias /var/www/trees/opentrees/static;
> }
>
> STATIC_ROOT is where those files are served from - in this case,
> /var/www/trees/opentrees/static
> This is also where collectstatic *puts* the files it finds when it's
> run. This directory, apparently (I discovered last night), should
> never
> be in your version control (git, svn, hg)
>
> STATICFILES_DIRS *is* in your version control. Each of these
> directories should be listed. This is where collectstatic *finds*
> static files to copy to STATIC_ROOT,
> Your proj/app structure looks like this:
>
> proj/static
> proj/app/static
>
> Add each of these to STATICFILES_DIRS.
>
> Admin, and other pip installed apps, will automatically be included (I think).
>
> I hope this helps.
>
> cheers
> L.
> ------
>
> I'm treading carefully
> but it's the time of night
> the snowy light
> the subway roar
> and the whispered fights
> exciting sights
> but it's not enough
> I thought it was
> I wish it was
> I thought it was
> -----
> You name it - The Cannanes with Explosion Robinson.
>
>
> On 23 April 2015 at 09:35, john <johnf@jfcomputer.com> 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.
>>
>> 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/5538303D.2080202%40jfcomputer.com.
>> For more options, visit https://groups.google.com/d/optout.
--
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/55383516.5000506%40jfcomputer.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment