Created
February 10, 2015 09:07
-
-
Save amitu/993b534e9322c6df7441 to your computer and use it in GitHub Desktop.
how to do static files in django/s3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% load static from versioned_static %} | |
<img src="{% static "img/transparentPixel.gif" %}"> | |
<!-- all css files use relative paths to refer static content --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CURRENT=${shell git rev-parse HEAD} | |
sync: | |
./build.sh min | |
s3cmd sync proj/staticfiles/admin/ s3://static.proj.com/admin/ | |
s3cmd sync proj/staticfiles/latest/ s3://static.proj.com/${CURRENT}/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# custom template | |
from django import template | |
from django.conf import settings | |
register = template.Library() | |
@register.simple_tag | |
def static(fragment): | |
return "%s%s/%s" % ( | |
(settings.STATIC_URL if settings.STATIC_URL else "/static/"), | |
settings.COMMIT_ID, fragment | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment