Metadata-Version: 2.0
Name: django-context-variables
Version: 0.0.3
Summary: Simple utility to help make declarative class-based views in Django
Home-page: https://github.com/carlmjohnson/django-context-variables
Author: Carl M. Johnson
Author-email: UNKNOWN
License: MIT
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Framework :: Django

# django-context-variables
Simple utility to help make declarative class-based views in Django


Each method on a CBV decorated with `context_variable` is evaluated once
per instance (==request) by the `get_context_variables` function and added
to the template's context.


##Usage
views.py:

    class MyCBV(TemplateView):
        template_name = "my_template.html"

        def get_context_data(self, **kwargs):
            return get_context_variables(self)

        @context_variable
        def page(self):
            return get_object_or_404(MyModel, self.kwargs.get('page_id'))

        @context_variable
        def page_title(self):
            return '%s - My Site' % self.page.title

my_template.html:

    <html>
        <title>{{ page_title }}</title>
        <body>
            {{ page.content }}
        </body>
    </html>


