<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr</title>
<link>http://snipplr.com/language/django/tags/django</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Fri, 24 May 2013 09:32:26 GMT</pubDate>
<item>
<title>(Django) Django: 3 ways to serve templates in views.py - chrisaiv</title>
<link>http://snipplr.com/view/62232/django-3-ways-to-serve-templates-in-viewspy/</link>
<description><![CDATA[ <p>There are so many ways to serve templates within views.py that sometimes it's hard to get a handle on which is ideal for a project.  This snippet does not attempt to explain every possible way to serve a template, simply a few I've found helpful organized from low-level (more code) to high-level (less code)</p> ]]></description>
<pubDate>Tue, 03 Jan 2012 03:36:32 GMT</pubDate>
<guid>http://snipplr.com/view/62232/django-3-ways-to-serve-templates-in-viewspy/</guid>
</item>
<item>
<title>(Django) Clean up expired django.contrib.session\'s in a huge MySQL InnoDB table - magicrebirth</title>
<link>http://snipplr.com/view/62190/clean-up-expired-djangocontribsessions-in-a-huge-mysql-innodb-table/</link>
<description><![CDATA[ <p>While django provides the django_admin.py cleanup script, if sessions get out of control sometimes you have to go lower level to get everything cleaned up. If the problem gets out of hand and you hit the resource limits of the machine, it is very difficult to get anything done in the database.

Attached is SQL code which was used to cleanup 27GB of expired session data in 3h. Run it like this to make sure it runs to completion:

`nohup mysql --user=username --password=password --host=hostname database < delete_expired_sessions.sql`

nohup causes the script to run detached from a terminal, so if your session gets disconnected it will keep running.

p.s.
An alternative approach is to launch this command from the shell:

DELETE FROM django_session WHERE expire_date < NOW();

or 

DELETE FROM django_session WHERE expire_date < "2011-12-10 00:00:00";</p> ]]></description>
<pubDate>Fri, 30 Dec 2011 23:12:12 GMT</pubDate>
<guid>http://snipplr.com/view/62190/clean-up-expired-djangocontribsessions-in-a-huge-mysql-innodb-table/</guid>
</item>
<item>
<title>(Django) Django: Configuring settings.py to rely on relative paths rather than absolute - chrisaiv</title>
<link>http://snipplr.com/view/62113/django-configuring-settingspy-to-rely-on-relative-paths-rather-than-absolute/</link>
<description><![CDATA[ <p>Hate absolute Paths? Me too, I always end up forgetting to change things around when I go into production mode.  Thankfully, there's a nice, clean way to have Python do all the hard work.</p> ]]></description>
<pubDate>Sat, 24 Dec 2011 03:24:17 GMT</pubDate>
<guid>http://snipplr.com/view/62113/django-configuring-settingspy-to-rely-on-relative-paths-rather-than-absolute/</guid>
</item>
<item>
<title>(Django) Django: check whether an object already exists before adding - magicrebirth</title>
<link>http://snipplr.com/view/59359/django-check-whether-an-object-already-exists-before-adding/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Mon, 03 Oct 2011 21:49:28 GMT</pubDate>
<guid>http://snipplr.com/view/59359/django-check-whether-an-object-already-exists-before-adding/</guid>
</item>
<item>
<title>(Django) Django if statement &amp;amp; loop - stewartduffy</title>
<link>http://snipplr.com/view/55083/django-if-statement--loop/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Thu, 09 Jun 2011 16:15:05 GMT</pubDate>
<guid>http://snipplr.com/view/55083/django-if-statement--loop/</guid>
</item>
<item>
<title>(Django) Adding custom django package to WSGI settings - magicrebirth</title>
<link>http://snipplr.com/view/54284/adding-custom-django-package-to-wsgi-settings/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 24 May 2011 00:05:01 GMT</pubDate>
<guid>http://snipplr.com/view/54284/adding-custom-django-package-to-wsgi-settings/</guid>
</item>
<item>
<title>(Django) Strip/Remove HTML tags (django utils) - magicrebirth</title>
<link>http://snipplr.com/view/50835/stripremove-html-tags-django-utils/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Sat, 19 Mar 2011 05:52:44 GMT</pubDate>
<guid>http://snipplr.com/view/50835/stripremove-html-tags-django-utils/</guid>
</item>
<item>
<title>(Django) Edit TEMPLATE_CONTEXT_PROCESSORS in your settings.py - caruso_g</title>
<link>http://snipplr.com/view/47789/edit-templatecontextprocessors-in-your-settingspy/</link>
<description><![CDATA[ <p>Instead of directly edit your TEMPLATE\_CONTEXT\_PROCESSORS, import it in your app's settings.py and just append what you need.

(credits: denysonique and all #django channel community)</p> ]]></description>
<pubDate>Mon, 24 Jan 2011 19:22:11 GMT</pubDate>
<guid>http://snipplr.com/view/47789/edit-templatecontextprocessors-in-your-settingspy/</guid>
</item>
<item>
<title>(Django) Django tut Blog Settings.py 1 - Affix</title>
<link>http://snipplr.com/view/47121/django-tut-blog-settingspy-1/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Fri, 14 Jan 2011 11:49:17 GMT</pubDate>
<guid>http://snipplr.com/view/47121/django-tut-blog-settingspy-1/</guid>
</item>
<item>
<title>(Django) Django simple url redirect - magicrebirth</title>
<link>http://snipplr.com/view/42051/django-simple-url-redirect/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Mon, 11 Oct 2010 21:43:13 GMT</pubDate>
<guid>http://snipplr.com/view/42051/django-simple-url-redirect/</guid>
</item>
<item>
<title>(Django) Timestamp Inherit Model (Versione 2) - munkypot</title>
<link>http://snipplr.com/view/41209/timestamp-inherit-model-versione-2/</link>
<description><![CDATA[ <p>Simula in Django i campi created e updated aggiornati automaticamente alla creazione e alla modifica del record (Versione 2 senza funzione save ridefinita)</p> ]]></description>
<pubDate>Fri, 01 Oct 2010 04:09:19 GMT</pubDate>
<guid>http://snipplr.com/view/41209/timestamp-inherit-model-versione-2/</guid>
</item>
<item>
<title>(Django) Django | Testing Django applications - magicrebirth</title>
<link>http://snipplr.com/view/34626/django--testing-django-applications/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Mon, 17 May 2010 10:07:44 GMT</pubDate>
<guid>http://snipplr.com/view/34626/django--testing-django-applications/</guid>
</item>
<item>
<title>(Django) Django: instantiating (simple) M2M models - magicrebirth</title>
<link>http://snipplr.com/view/27157/django-instantiating-simple-m2m-models/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Wed, 27 Jan 2010 07:25:25 GMT</pubDate>
<guid>http://snipplr.com/view/27157/django-instantiating-simple-m2m-models/</guid>
</item>
<item>
<title>(Django) ModelAdmin media definitions - magicrebirth</title>
<link>http://snipplr.com/view/27093/modeladmin-media-definitions/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 26 Jan 2010 09:57:07 GMT</pubDate>
<guid>http://snipplr.com/view/27093/modeladmin-media-definitions/</guid>
</item>
<item>
<title>(Django) modify django admin field to use specific queryset and form widget - magicrebirth</title>
<link>http://snipplr.com/view/27092/modify-django-admin-field-to-use-specific-queryset-and-form-widget/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 26 Jan 2010 09:55:25 GMT</pubDate>
<guid>http://snipplr.com/view/27092/modify-django-admin-field-to-use-specific-queryset-and-form-widget/</guid>
</item>
<item>
<title>(Django) Django send email through Gmail - martin_rusev</title>
<link>http://snipplr.com/view/26605/django-send-email-through-gmail/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Sun, 17 Jan 2010 07:09:05 GMT</pubDate>
<guid>http://snipplr.com/view/26605/django-send-email-through-gmail/</guid>
</item>
<item>
<title>(Django) Custom validation message - martin_rusev</title>
<link>http://snipplr.com/view/26567/custom-validation-message/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Sat, 16 Jan 2010 15:01:33 GMT</pubDate>
<guid>http://snipplr.com/view/26567/custom-validation-message/</guid>
</item>
<item>
<title>(Django) Send HTML templates with Django - martin_rusev</title>
<link>http://snipplr.com/view/26566/send-html-templates-with-django/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Sat, 16 Jan 2010 14:58:06 GMT</pubDate>
<guid>http://snipplr.com/view/26566/send-html-templates-with-django/</guid>
</item>
<item>
<title>(Django) Django: access the attributes of a model dynamically - magicrebirth</title>
<link>http://snipplr.com/view/25243/django-access-the-attributes-of-a-model-dynamically/</link>
<description><![CDATA[ <p>example: a method on a model that outputs a list of tuples with (attribute_name.verbose, attribute_value)</p> ]]></description>
<pubDate>Tue, 22 Dec 2009 15:17:20 GMT</pubDate>
<guid>http://snipplr.com/view/25243/django-access-the-attributes-of-a-model-dynamically/</guid>
</item>
<item>
<title>(Django) Django: adding new admin_tags - magicrebirth</title>
<link>http://snipplr.com/view/25238/django-adding-new-admintags/</link>
<description><![CDATA[ <p>First: create a file under djangoapp/templatetags where you define your tags [e.g.: myadmin_tags.py]:

Second: create the html snippets that get loaded in those tags [e.g., personfactoid_info.html]:

Third: in mytemplates/admin/ modify change_form.html (if you don't have it just copy it from the django-admin app). You must add a placeholder for the new templatetags (probably you want to add it at the bottom of the page):

FOurth: create a new change_form.html in the same directory as above, but under your model template [e.g., mytemplates/admin/myapp/mymodel/change_form.html] so to override the behaviour just for that. The 'object_id' variable is passed by the admin template by default:</p> ]]></description>
<pubDate>Tue, 22 Dec 2009 15:06:14 GMT</pubDate>
<guid>http://snipplr.com/view/25238/django-adding-new-admintags/</guid>
</item>
</channel>
</rss>