Skip to main content

Django script pattern app

Project description

django-script-pattern

This app allows you to add script blocks into your pages using url patterns like:

  • /category/*

  • /*/subcategory/*

# Includes GET parameters

  • /products/catalog/*category=some-category*

Use * to pass any symbols and $ as the end.

Available to use four block locations:

  1. Head - Top

  2. Head - Bottom

  3. Body - Top

  4. Body - Bottom

Installation

Install with pip:

$ pip install django-script-pattern

Update INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'script_pattern',
    'django-admin-sortable2',
    'django_jinja',  # optional for jinja2 global function
    ...
]

Apply migrations:

$ python manage.py migrate

Example to use:

#layout.jinja
<html lang="en">
    <head>
        {{ get_script_pattern(request, 'head', 'top') }}
        ...
        some head content
        ...
        {{ get_script_pattern(request, 'head', 'bottom') }}
    </head>

    <body>
        {{ get_script_pattern(request, 'body', 'top') }}
        ...
        some body content
        ...
        {{ get_script_pattern(request, 'body', 'bottom') }}
    </body>
</html>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-script-pattern-0.2.tar.gz (5.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page