(mapping)
return decorator
Like the *page_template* decorator but manage multiple paginations.

    You can map multiple templates to *querystring_keys* using the *mapping*
    dict, e.g.::

        @page_templates({
            'page_contents1.html': None,
            'page_contents2.html': 'go_to_page',
        })
        def myview(request):
            ...

    When the value of the dict is None then the default *querystring_key*
    (defined in settings) is used. You can use this decorator instead of
    chaining multiple *page_template* calls.
Like the *page_template* decorator but manage multiple paginations.
Like the * page_template * decorator but manage multiple paginations .
def page_templates(mapping):
    """Like the *page_template* decorator but manage multiple paginations.

    You can map multiple templates to *querystring_keys* using the *mapping*
    dict, e.g.::

        @page_templates({
            'page_contents1.html': None,
            'page_contents2.html': 'go_to_page',
        })
        def myview(request):
            ...

    When the value of the dict is None then the default *querystring_key*
    (defined in settings) is used. You can use this decorator instead of
    chaining multiple *page_template* calls.
    """
    def decorator(view):
        @wraps(view)
        def decorated(request, *args, **kwargs):
            # Trust the developer: he wrote ``context.update(extra_context)``
            # in his view.
            extra_context = kwargs.setdefault('extra_context', {})
            querystring_key = request.REQUEST.get(
                'querystring_key', PAGE_LABEL)
            template = _get_template(querystring_key, mapping)
            extra_context['page_template'] = template
            # Switch the template when the request is Ajax.
            if request.is_ajax() and template:
                kwargs[TEMPLATE_VARNAME] = template
            return view(request, *args, **kwargs)
        return decorated

    return decorator
def page_templates ( mapping ) : def decorator ( view ) : @ wraps ( view ) def decorated ( request , * args , * * kwargs ) : # Trust the developer: he wrote ``context.update(extra_context)`` # in his view. extra_context = kwargs . setdefault ( 'extra_context' , { } ) querystring_key = request . REQUEST . get ( 'querystring_key' , PAGE_LABEL ) template = _get_template ( querystring_key , mapping ) extra_context [ 'page_template' ] = template # Switch the template when the request is Ajax. if request . is_ajax ( ) and template : kwargs [ TEMPLATE_VARNAME ] = template return view ( request , * args , * * kwargs ) return decorated return decorator