skip to navigation
skip to content

Not Logged In

django-section 0.0.3

Django app for determining site section by request.

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.

 
File Type Py Version Uploaded on Size
django-section-0.0.3.tar.gz (md5) Source 2011-08-24 3KB
django_section-0.0.3-py2.6.egg (md5) Python Egg 2.6 2011-08-24 6KB
django_section-0.0.3-py2.7.egg (md5) Python Egg 2.7 2011-08-24 6KB
  • Downloads (All Versions):
  • 43 downloads in the last day
  • 153 downloads in the last week
  • 784 downloads in the last month