Skip to content

Instantly share code, notes, and snippets.

@amitu
Created February 10, 2015 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitu/993b534e9322c6df7441 to your computer and use it in GitHub Desktop.
Save amitu/993b534e9322c6df7441 to your computer and use it in GitHub Desktop.
how to do static files in django/s3
{% load static from versioned_static %}
<img src="{% static "img/transparentPixel.gif" %}">
<!-- all css files use relative paths to refer static content -->
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}/
# 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