djangosnippets.org: Latest snippets tagged with 'active'https://djangosnippets.org/tags/active/2013-05-23T01:50:49.068525-05:00Simple templatetag to mark navigation as active using view names or regex
2013-05-23T01:50:49.068525-05:00gluchethttps://djangosnippets.org/snippets/2923/<p>Theses two templatetags make easy to add an active class on a navigation link. The first one is based on a regexp an search if the request path match it. The second one simply use view names.</p>
Freely redistributableActive link
2011-11-30T13:29:47.042092-06:00ronniehttps://djangosnippets.org/snippets/2617/<p>I needed a way to find if a menu items should be active. After searching the internet i found a few options*, but none of them did fit my needs, so i wrote my own:</p>
<p>Usage:
<a href="{% url 'view-name' %}"></a></p>
<ul>
<li>http://gnuvince.wordpress.com/2008/03/19/the-new-and-improved-active-tag/</li>
<li>http://stackoverflow.com/questions/340888/navigation-in-django</li>
</ul>
Freely redistributableUsing URLs for highlighting sections in menu
2010-08-09T17:15:18.659869-05:00divermanhttps://djangosnippets.org/snippets/2143/<p>Use this, if you want to "activate" menu items by URL. Typical usage is with CSS class 'active'.</p>
Freely redistributableActive class for navigation link
2009-09-14T04:20:49.036480-05:00cschandhttps://djangosnippets.org/snippets/1726/<p>Active class for navigation link</p>
<p>{% navclass default current url %}</p>
<pre><code> First argument is the default class and second is the current class
Third argument is the url name(s) of the page
example: <a class="{% navclass leftnav curentnav name1,name2 %}" href="/about/">
</code></pre>
Freely redistributableActive / Inactive model manager
2009-05-27T16:19:19.577400-05:00bendavis78https://djangosnippets.org/snippets/1533/<p>Used for models with active_date and inactive_date. Adds an "active" filter to get only active items</p>
Freely redistributabletemplate tag for highlighting currently active page
2008-10-23T13:56:57.262523-05:00adunarhttps://djangosnippets.org/snippets/1153/<p>This module defines a template tag <code>{% ifactive %}</code> that lets you determine which page is currently active. A common use case is for highlighting the current page in a navigation menu.
</p>
<p>It uses the same syntax for specifying views as the <code>{% url %}</code> tag, and determines whether a …</p>
Freely redistributableActiveManager: filter objects depending on publication and/or expiration dates
2008-07-01T05:31:22.869286-05:00haplohttps://djangosnippets.org/snippets/838/<p>This manager is intended for use with models with publication and/or expiration dates. Objects will be retrieved only if their publication and/or expiration dates are within the current date.</p>
<p>Use is very simple:</p>
<pre><code>class ExampleModel(models.Model):
publish_date = models.DateTimeField()
expire_date = models.DateTimeField(blank=True, null=True)
objects = models.Manager()
actives = ActiveManager(from_date='publish_date', to_date='expire_date')
ExampleModel.actives.all() …</code></pre>
Freely redistributable