On Fri, Mar 7, 2014 at 4:08 AM, Vernon Burt <charger...@gmail.com> wrote:
> Hello all,
>
> I've pretty quikly found out in my DJango adventure that I need to have some
> kind of versioning for my static css and javascript files. After talking to
> some web developers I was directed to use Django's CachedStaticFilesStorage
> app to append an md5 hash to the static files path. No matter how I set my
> static settings the files don't seem to get the has appended and  I can no
> longer link to any of my static files, either directly or using the static
> directive. I was wondering if anyone might know what I am doing wrong.
>
> My  Settings:
>
> STATIC_ROOT = 'staticfiles'
>
> STATIC_URL = ''

This doesn't look right. STATIC_ROOT is the name of the directory that
django copies the static files to when you run collectstatic. This
should probably be an absolute path to avoid problems when django is
run from a different working directory.

STATIC_URL is the URL that you have configured your webserver to serve
the files that django copied in to STATIC_ROOT. It should *NOT* be
empty. Most people put it to '/static/'.

Two of the conditions for CachedStaticFilesStorage are that
DEBUG=False and that you have re-run collectstatic? If you have done
so, is STATIC_ROOT full of lovely files with md5 hashes in their
names?

Remember you will need to run collectstatic every time you change a file.


>
> # Additional locations of static files
> STATICFILES_DIRS = (
> )
>
> STATICFILES_FINDERS = (
>     'django.contrib.staticfiles.finders.FileSystemFinder',
>     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
> )
>
> STATICFILES_STORAGE =
> 'django.contrib.staticfiles.storage.CachedStaticFilesStorage'
>
>
> My Template entry:
>
> {% block cssfiles %}
> {% load static%}
> <link href="{% static "/static/css/map.css" %}" media="screen">
> {% endblock %}

So this is intended to find a file in "my_app_name/static/static/css/map.css"?

This is just a tip - always put the name of your app as the first part
of the static name, so "my_app_name/static/my_app_name/css/map.css",
referred to in the template as "{% static 'my_app_name/css/map.css'
%}". This avoids conflicts with other apps that might have a map.css.

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+unsubscr...@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/CAFHbX1J%3Ds2PQg%2Bxm0kteARvNTW4K%2B-1SJfDh%3DO9_xAKcT594VQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to