<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>rixx.de (Posts about development)</title><link>https://rixx.de/</link><description></description><atom:link href="https://rixx.de/categories/development.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><lastBuildDate>Wed, 19 Feb 2025 15:35:17 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>A @context decorator for Django</title><link>https://rixx.de/blog/a-context-decorator-for-django/</link><dc:creator>rixx</dc:creator><description>&lt;div&gt;&lt;p&gt;Even the happiest Django developers with the most ardent love of &lt;a href="https://ccbv.co.uk/"&gt;class-based views&lt;/a&gt; can get tired
of writing &lt;code&gt;super().get_context_data(**kwargs)&lt;/code&gt;, only to add a couple of already-implemented properties or methods to
the template context.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;django-context-decorator&lt;/code&gt; provides, as the name may hint at, a decorator named &lt;code&gt;@context&lt;/code&gt;. You can wrap it around
both methods and properties, including Django's &lt;a href="https://docs.djangoproject.com/en/dev/ref/utils/#django.utils.functional.cached_property"&gt;cached
property&lt;/a&gt;, and it will add the
property's value or the method's return value to your template context:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://rixx.de/blog/a-context-decorator-for-django/"&gt;Read more…&lt;/a&gt; (3 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>development</category><category>django</category><category>project</category><guid>https://rixx.de/blog/a-context-decorator-for-django/</guid><pubDate>Wed, 17 Apr 2019 22:32:43 GMT</pubDate></item></channel></rss>