Skip to main content

Django app for determining site section by request.

Project description

Django app for determining site section by request.

Installation

  1. Add section.context_processors.section to TEMPLATE_CONTEXT_PROCESSORS in your settings file:

    TEMPLATE_CONTEXT_PROCESSORS = (
        "django.contrib.auth.context_processors.auth",
        "django.core.context_processors.debug",
        "django.core.context_processors.i18n",
        "django.core.context_processors.media",
        "django.contrib.messages.context_processors.messages",
        "section.context_processors.section")
  2. Add SECTIONS value to your settings file in the form:

    # Tuple of dictionaries used to match URL pattern names to site sections.
    # example: ({'name': '<section name>', 'matching_pattern_names': ('<url_name1>', '<url_name2>')},)
    SECTIONS = (
        {'name': 'home', 'matching_pattern_names': ('home',)},
    )

Usage

If you’re using generic views you’ll now automagically have a section variable added to context and available in your templates.

Otherwise have a look at RequestContext objects and how to use them:

http://docs.djangoproject.com/en/dev/ref/templates/api/#id1

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-section-0.0.1.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distributions

django_section-0.0.1-py2.6.egg (4.5 kB view hashes)

Uploaded Source

django_section-0.0.1-py2.5.egg (4.5 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