Django Static Files: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
(Created page with "Category:Django Category:Web Development == Overview == Collection of information about how to manage static files with Django. == Settings == Place app-specific st...")
(No difference)

Revision as of 01:23, 12 February 2016

Overview

Collection of information about how to manage static files with Django.

Settings

Place app-specific static resources in the app's directory, e.g. myapp/static/myapp/images/myapp-bg.png. When looking up static resources, Django will place the first file that matches a name. Placing the file inside the app's directory effectively namespaces it.

Reference the asset in Django templates using the static template tag:

<link rel="stylesheet" type="text/css" href="{% static 'myapp/app.css' %}">

Or with the static function in Jinja2 templates:

<link rel="stylesheet" type="text/css" href="{{ static('myapp/app.css') }}">

Notes

See also