Skip to main content

Django app for determining site section by request.

Project description

Django Section

Django app for determining site section by request.

Installation

  1. Add section.context_processors.section to your TEMPLATE_CONTEXT_PROCESSORS setting:

    TEMPLATE_CONTEXT_PROCESSORS = (
        ...other context processors...,
        "section.context_processors.section",
    )
  2. Add SECTIONS setting 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 or RequestContext you’ll now automagically have a section variable added to context and available in your templates containing the value of name as defined for the current view in your SECTIONS setting.

NOTE: If the current path can not be resolved to a defined section, the first section as defined in the SECTION settings is returned. This allows you to setup a global fallback section, i.e. home.

Authors

Praekelt Foundation

  • Shaun Sephton

Changelog

0.0.2 (2011-08-24)

  1. Docs, tests.

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.3.tar.gz (4.0 kB view details)

Uploaded Source

Built Distributions

django_section-0.0.3-py2.7.egg (6.3 kB view details)

Uploaded Source

django_section-0.0.3-py2.6.egg (6.4 kB view details)

Uploaded Source

File details

Details for the file django-section-0.0.3.tar.gz.

File metadata

File hashes

Hashes for django-section-0.0.3.tar.gz
Algorithm Hash digest
SHA256 88121c8877d9077f46e6c95cdb6b37d69b09f02ee70280b56ef715395937ace5
MD5 d74c4177d445847a73b1d8e87495881b
BLAKE2b-256 500f59727ed5c7ab99d30c59bc53abafffb34b2899f3ecfa1580999cc171c8e0

See more details on using hashes here.

File details

Details for the file django_section-0.0.3-py2.7.egg.

File metadata

File hashes

Hashes for django_section-0.0.3-py2.7.egg
Algorithm Hash digest
SHA256 613200870551d8dbf62dc88c381305b3a0999373de3517d39788444ec606aad4
MD5 d84d02cea41444a967ecdd8b61226c87
BLAKE2b-256 7d5d1375824d2cb30b3ac017bc9dce36d98aef4d95bcad4a8011a0b65c012bf3

See more details on using hashes here.

File details

Details for the file django_section-0.0.3-py2.6.egg.

File metadata

File hashes

Hashes for django_section-0.0.3-py2.6.egg
Algorithm Hash digest
SHA256 22a4f62c9694c5021e19b3e422a2261782005df19615a680f1f0f8f560676ea0
MD5 13ea89676fa15d35320fee7cf1c4a5e8
BLAKE2b-256 595db19d4e2b44c738422a72ad74bef12db09283fa1163f7aebfa65ce2628c22

See more details on using hashes here.

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