Wednesday, March 6, 2013

Re: empty static_url

Hi Tom,

Thanks a million for the reply, you helped solve my issue.

Technically speaking, if that is your template, and you end up with
"/css/style.css", then STATIC_URL is not empty, it is '/'.

Yeah sorry, I should have just had "css/style.css" as I wasn't even getting the forward slash.

Yes thats correct, 1 project with 3 apps etc. I just changed the last line in my view(that wasn't working, not the 2 generic view ones) from...

return render_to_response('sales/index.html', {'sales_list': sales_list})

to...

return render_to_response('sales/index.html', {'sales_list': sales_list},context_instance=RequestContext(request))

and that did the job. Thanks again.





On Monday, March 4, 2013 2:33:50 PM UTC, Tom Evans wrote:
On Sat, Mar 2, 2013 at 4:47 PM, Phil <phi...@gmail.com> wrote:
> Hi,
>
> I'm using django1.4.3
>
> I have a django project with 3 apps. All 3 apps templates extend 'app.html'.
> On 2 of my projects the CSS loads fine, but on third one the CSS doesn't get
> loaded because it's not adding '/static/' to the url to the CSS. So instead
> of '/static/css/style.css' I'm getting '/css/style.css' ...
>
> <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/style.css">

Technically speaking, if that is your template, and you end up with
"/css/style.css", then STATIC_URL is not empty, it is '/'.

>
> STATIC_URL is working on the 2 projects that use generic views, but not on
> the other one. So how can 'STATIC_URL' be blank and how can this be fixed? I
> tried adding the following to my index.html template but no joy...
>
> {% load static %}
> {% get_static_prefix as STATIC_PREFIX %}
>

To clarify - you only have one project, with three apps in it. In two
of the apps, which only use generic views, STATIC_URL works correctly,
but in third app it does not.

Do these views in the third app use RequestContext to render the
templates? Generic views do…

Cheers

Tom

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment