Skip to content

Staticloader is a simple Django app which provides template tags for loading JavaScript and CSS files into the template.

License

Notifications You must be signed in to change notification settings

izderic/django-staticloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-staticloader

Staticloader is a simple Django app which provides template tags for loading JavaScript and CSS files into the template.

Installation

Install using pip:

pip install git+git://github.com/izderic/django-staticloader.git

Quick start

  1. Add "staticloader" to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = (
        ...
        'staticloader',
    )
    
  2. Define dictionaries JS_FILES and CSS_FILES in your Django settings file like this:

    # settings.py
    # ============
    
    JS_FILES = {
        'myCustomScript': 'js/myCustomScript.js',
        'exampleScript': 'js/exampleScript.js',
        ...
    }
    
    CSS_FILES = {
        'style': 'css/style.css',
        'otherStyle': 'css/otherStyle.css',
        ...
    }
  3. In your template add {% load staticloader_tags %} on the top.

  4. Use template tags {% loadjs %} and {% loadcss %} to include the files defined in settings.

    {% loadcss "style" "otherStyle" %}
    {% loadjs "myCustomScript" "exampleScript" %}

About

Staticloader is a simple Django app which provides template tags for loading JavaScript and CSS files into the template.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published