{ "info": { "author": "Carl M. Johnson", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3" ], "description": "# django-context-variables\nSimple utility to help make declarative class-based views in Django\n\n\nEach method on a CBV decorated with `context_variable` is evaluated once\nper instance (==request) by the `get_context_variables` function and added\nto the template's context.\n\n\n##Usage\nviews.py:\n\n class MyCBV(TemplateView):\n template_name = \"my_template.html\"\n\n def get_context_data(self, **kwargs):\n return get_context_variables(self)\n\n @context_variable\n def page(self):\n return get_object_or_404(MyModel, self.kwargs.get('page_id'))\n\n @context_variable\n def page_title(self):\n return '%s - My Site' % self.page.title\n\nmy_template.html:\n\n \n