djangosnippets.org: Latest snippets posted by tgandorhttps://djangosnippets.org/users/tgandor/2014-05-11T23:54:10.973292-05:00tgandorConditional INSTALLED_APPS entry
2014-05-11T23:54:10.973292-05:00tgandorhttps://djangosnippets.org/snippets/3048/<p>Some INSTALLED_APPLICATIONS applications may not be critical for your website to work - for example you may only need them for development - like 'django_extensions' or 'debug_toolbar'. They needn't be installed actually for the site to work. </p>
<p>This way you can avoid discussions with other developers if some application should …</p>
Freely redistributableRead-only Model Form Base Class
2014-04-14T06:49:35.222993-05:00tgandorhttps://djangosnippets.org/snippets/3040/<p>The simplest way of displaying a "details" table about any model, is to show a ModelFrom with all fields readonly or (selects) disabled.</p>
<p>Also, the labels are preferably translatable, not just capitalized names of the column tables in your models. So the constructor translates the field labels as well.</p>
Freely redistributableTemplate tag and filter for displaying number of years since
2014-03-22T04:43:20.965085-05:00tgandorhttps://djangosnippets.org/snippets/3037/<p>Because {% now "Y"|add:"-2005" %} - etc. doesn't work, you can use the above in your template like:</p>
<p>We have {{ 2000|since }} years of experience.</p>
<p>or:</p>
<p>Serving our customers with passion for more than {% years_since 2005 %} years.</p>
Freely redistributableView all log entries in the admin 2
2013-12-11T02:53:15.256320-06:00tgandorhttps://djangosnippets.org/snippets/3009/<p>Based on:
<a href="https://djangosnippets.org/snippets/2484/">View all log entries in the admin</a></p>
<p>Improvements:</p>
<ul>
<li>No crash on <code>object_link</code> when reverse route missing,</li>
<li>Filter by users present in the log AND in database currently</li>
<li>Other filters on users - only superusers / only staff (modify to fit your needs)</li>
</ul>
<p>EDIT:</p>
<p>Incorporated <code>action_description</code> from <a href="https://github.com/yprez/django-logentry-admin">django-logentry-admin</a>. …</p>
Freely redistributable