<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.2.1">Jekyll</generator><link href="https://www.djangorocks.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://www.djangorocks.com/" rel="alternate" type="text/html" /><updated>2025-05-05T17:10:05+00:00</updated><id>https://www.djangorocks.com/feed.xml</id><title type="html">Django Rocks</title><subtitle>DjangoRocks - A site with Django Snippets, Tutorials and maybe interesting Blog Articles.</subtitle><entry><title type="html">Django development server / runserver replacement</title><link href="https://www.djangorocks.com/2010/12/02/django-development-server-runserver-replacement" rel="alternate" type="text/html" title="Django development server / runserver replacement" /><published>2010-12-02T19:22:07+00:00</published><updated>2010-12-02T19:22:07+00:00</updated><id>https://www.djangorocks.com/2010/12/02/django-development-server-runserver-replacement</id><content type="html" xml:base="https://www.djangorocks.com/2010/12/02/django-development-server-runserver-replacement">&lt;p&gt;My usual development install of Django has consisted of the following;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.djangoproject.com&quot;&gt;Django&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://code.google.com/p/django-compress/&quot;&gt;django-compress&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/robhudson/django-debug-toolbar&quot;&gt;django-debug-toolbar&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Custom addons I’ve built&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Today, I come across something else that might make it into my development dev install.  &lt;a href=&quot;https://github.com/dcramer/django-devserver&quot;&gt;django-devserver&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The default &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;runserver&lt;/code&gt; is pretty good to get going quickly.  However &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;django-devserver&lt;/code&gt; includes some nice extras specifically for the development process. The following are displayed in the terminal, depending on config;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;SQL queries&lt;/li&gt;
  &lt;li&gt;Profile summary&lt;/li&gt;
  &lt;li&gt;Cache summary&lt;/li&gt;
  &lt;li&gt;Memory use&lt;/li&gt;
  &lt;li&gt;AJAX output&lt;/li&gt;
  &lt;li&gt;Session info&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;django-devserver&lt;/code&gt; is also available for install using &lt;a href=&quot;http://pypi.python.org/pypi/django-devserver&quot;&gt;easy_install&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note: The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;django-devserver&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;django-debug-toolbar&lt;/code&gt; don’t play well together.&lt;/p&gt;</content><author><name></name></author><summary type="html">My usual development install of Django has consisted of the following;</summary></entry><entry><title type="html">New Tutorial - Custom / IMAP Authentication Backend</title><link href="https://www.djangorocks.com/2010/11/13/new-tutorial-custom-imap-authentication-backend" rel="alternate" type="text/html" title="New Tutorial - Custom / IMAP Authentication Backend" /><published>2010-11-13T13:28:40+00:00</published><updated>2010-11-13T13:28:40+00:00</updated><id>https://www.djangorocks.com/2010/11/13/new-tutorial-custom-imap-authentication-backend</id><content type="html" xml:base="https://www.djangorocks.com/2010/11/13/new-tutorial-custom-imap-authentication-backend">&lt;p&gt;I thought it was time to add another tutorial - and this news post, in an attempt to keep the site updated.&lt;/p&gt;

&lt;p&gt;Last week I added &lt;a href=&quot;/snippets/running-from-a-cron-job-scheduled-task&quot;&gt;Running from a Cron Job (Scheduled task)&lt;/a&gt; into the Hints &amp;amp; Tips section.&lt;/p&gt;

&lt;p&gt;Today, I have added &lt;a href=&quot;/tutorials/creating-a-custom-authentication-backend&quot;&gt;Creating a Custom Authentication Backend&lt;/a&gt; to the Tutorials.&lt;/p&gt;

&lt;p&gt;As the name suggests, the idea is to create an alternative authentication method for your Django application.  In this case I have chosen IMAP as it was a simple backend to implement.  It’s a little shorter than I would like for a tutorial, but better than nothing.&lt;/p&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;</content><author><name></name></author><summary type="html">I thought it was time to add another tutorial - and this news post, in an attempt to keep the site updated.</summary></entry><entry><title type="html">Django 1.2 E-commerce review</title><link href="https://www.djangorocks.com/2010/09/02/django-1-2-e-commerce-review" rel="alternate" type="text/html" title="Django 1.2 E-commerce review" /><published>2010-09-02T19:08:50+00:00</published><updated>2010-09-02T19:08:50+00:00</updated><id>https://www.djangorocks.com/2010/09/02/django-1-2-e-commerce-review</id><content type="html" xml:base="https://www.djangorocks.com/2010/09/02/django-1-2-e-commerce-review">&lt;p&gt;I have finally added the first review in the recommended reading section.  There really should be a real reviews section, at the moment it’s just a static page…unfortunately time constraints are weighing heavy at the moment.&lt;/p&gt;

&lt;p&gt;So, anyway, &lt;a href=&quot;/recommended-reading/django-12-e-commerce&quot;&gt;here it is&lt;/a&gt;.&lt;/p&gt;</content><author><name></name></author><summary type="html">I have finally added the first review in the recommended reading section. There really should be a real reviews section, at the moment it’s just a static page…unfortunately time constraints are weighing heavy at the moment.</summary></entry><entry><title type="html">New “Recommended Reading”</title><link href="https://www.djangorocks.com/2010/06/02/new-recommended-reading" rel="alternate" type="text/html" title="New &quot;Recommended Reading&quot;" /><published>2010-06-02T18:51:47+00:00</published><updated>2010-06-02T18:51:47+00:00</updated><id>https://www.djangorocks.com/2010/06/02/new-recommended-reading</id><content type="html" xml:base="https://www.djangorocks.com/2010/06/02/new-recommended-reading">&lt;p&gt;For when Tutorials &amp;amp; Snippets just are not enough to learn some aspects of Django in detail, this site now has a &lt;a href=&quot;/recommended-reading&quot;&gt;recommended reading&lt;/a&gt; section.&lt;/p&gt;

&lt;p&gt;This has books that I personally have read, or am reading.  There are currently two books listed, both really do go hand in hand. Django 1.2 E-commerce &amp;amp; Django 1.1 Testing and Debugging.  More details on these is available &lt;a href=&quot;/recommended-reading&quot;&gt;here&lt;/a&gt; as well as reviews to come in the near future.&lt;/p&gt;

&lt;p&gt;Details of the 2 books &amp;amp; Sample chapters are also available from the publishers sites;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.packtpub.com/django-1-2-e-commerce-build-powerful-applications/book?utm_source=djangorocks.com&amp;amp;utm_medium=bookrev&amp;amp;utm_content=blog&amp;amp;utm_campaign=mdb_003536&quot;&gt;Django 1.2 E-commerce&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.packtpub.com/django-1-1-testing-and-debugging/book?utm_source=djangorocks.com&amp;amp;utm_medium=bookrev&amp;amp;utm_content=blog&amp;amp;utm_campaign=mdb_003535&quot;&gt;Django 1.1 Testing and Debugging&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name></name></author><summary type="html">For when Tutorials &amp;amp; Snippets just are not enough to learn some aspects of Django in detail, this site now has a recommended reading section.</summary></entry><entry><title type="html">Mail Staff</title><link href="https://www.djangorocks.com/2009/12/13/mail-staff" rel="alternate" type="text/html" title="Mail Staff" /><published>2009-12-13T11:46:16+00:00</published><updated>2009-12-13T11:46:16+00:00</updated><id>https://www.djangorocks.com/2009/12/13/mail-staff</id><content type="html" xml:base="https://www.djangorocks.com/2009/12/13/mail-staff">&lt;p&gt;I decided on another for the Hints &amp;amp; Tips, giving you the ability to E-mail your staff, rather than admins or managers, both require updating the settings file.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/snippets/mail-staff&quot;&gt;Mail Staff&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’ve also created a Hints &amp;amp; Tips news category.&lt;/p&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;</content><author><name></name></author><summary type="html">I decided on another for the Hints &amp;amp; Tips, giving you the ability to E-mail your staff, rather than admins or managers, both require updating the settings file.</summary></entry><entry><title type="html">Hints &amp;amp; Tips, better than nothing :)</title><link href="https://www.djangorocks.com/2009/11/18/hints-tips-better-than-nothing" rel="alternate" type="text/html" title="Hints &amp; Tips, better than nothing :)" /><published>2009-11-18T17:46:28+00:00</published><updated>2009-11-18T17:46:28+00:00</updated><id>https://www.djangorocks.com/2009/11/18/hints-tips-better-than-nothing</id><content type="html" xml:base="https://www.djangorocks.com/2009/11/18/hints-tips-better-than-nothing">&lt;p&gt;Well, unfortunatly, I have not yet had time to test the tutorials.  So instead, I’ve added 3 posts to Hints &amp;amp; Tips&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;/snippets/indexing-your-django-models&quot;&gt;Indexing your Django models&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/snippets/set-created-updated-datetime-in-your-models&quot;&gt;Set created &amp;amp; updated date/time in your models&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/snippets/deleting-multiple-rows-from-your-database&quot;&gt;Deleting multiple rows from your database&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hopefully these help with your Django application development and I honestly do intend finishing off the tutorials.&lt;/p&gt;</content><author><name></name></author><summary type="html">Well, unfortunatly, I have not yet had time to test the tutorials. So instead, I’ve added 3 posts to Hints &amp;amp; Tips</summary></entry><entry><title type="html">New Tutorials……soon</title><link href="https://www.djangorocks.com/2009/11/02/new-tutorials-soon" rel="alternate" type="text/html" title="New Tutorials......soon" /><published>2009-11-02T17:46:02+00:00</published><updated>2009-11-02T17:46:02+00:00</updated><id>https://www.djangorocks.com/2009/11/02/new-tutorials-soon</id><content type="html" xml:base="https://www.djangorocks.com/2009/11/02/new-tutorials-soon">&lt;p&gt;My apologies.  I had intended on adding 2 new tutorials this last weekend, as well as another way to create unique slugs, however my time has been required elsewhere.  Because of this I have not yet been able to finish checking the tutorials. I would prefer to know they work, rather than having an epic fail moment.  Hopefully these will be up and running in the next few days, along with a couple of other additions to the sites functionality.&lt;/p&gt;</content><author><name></name></author><summary type="html">My apologies. I had intended on adding 2 new tutorials this last weekend, as well as another way to create unique slugs, however my time has been required elsewhere. Because of this I have not yet been able to finish checking the tutorials. I would prefer to know they work, rather than having an epic fail moment. Hopefully these will be up and running in the next few days, along with a couple of other additions to the sites functionality.</summary></entry><entry><title type="html">Dynamic Forms</title><link href="https://www.djangorocks.com/2009/10/15/dynamic-forms" rel="alternate" type="text/html" title="Dynamic Forms" /><published>2009-10-15T14:07:54+00:00</published><updated>2009-10-15T14:07:54+00:00</updated><id>https://www.djangorocks.com/2009/10/15/dynamic-forms</id><content type="html" xml:base="https://www.djangorocks.com/2009/10/15/dynamic-forms">&lt;p&gt;Recently I have been doing work with form fields populated from the database.  Obviously this, as standard, is not supported by Django.&lt;/p&gt;

&lt;p&gt;After quite some time search, and 3 different approaches to this I decided to make my own.  It has not been fully tested yet, but once it has I will post the code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I havn’t released this class yet so don’t go trying it&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To give you an idea as to the usage, note &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dfm&lt;/code&gt; is (currently) a 12 line class for convenience only, you could easily work without it.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FormOption&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;dfm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;forms&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BooleanField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;required&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;TheForm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dfm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_TheForm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;method&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'POST'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TheForm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;form&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TheForm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;As you can see, after the first few lines, you go back to your normal Django code.  It works with only a few dynamic fields, as well as displays the fields in the order you defined them.  That was the main problem at least one of the alternatives I found.&lt;/p&gt;

&lt;p&gt;You are also able to create your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;clean&lt;/code&gt; function in the forms to do some basic validation.&lt;/p&gt;

&lt;p&gt;Expect this in a few weeks after some more testing has been done.&lt;/p&gt;</content><author><name></name></author><summary type="html">Recently I have been doing work with form fields populated from the database. Obviously this, as standard, is not supported by Django.</summary></entry><entry><title type="html">Internationalization (i18n)</title><link href="https://www.djangorocks.com/2009/09/27/internationalisation" rel="alternate" type="text/html" title="Internationalization (i18n)" /><published>2009-09-27T21:23:27+00:00</published><updated>2009-09-27T21:23:27+00:00</updated><id>https://www.djangorocks.com/2009/09/27/internationalisation</id><content type="html" xml:base="https://www.djangorocks.com/2009/09/27/internationalisation">&lt;p&gt;Yesterday, I started work on using Django’s i18n to build my first multi-lingual site.&lt;/p&gt;

&lt;p&gt;I must say, the initial setup took me quite some time.&lt;/p&gt;

&lt;p&gt;A brief overview of the setup&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Add the middleware (easy)&lt;/li&gt;
  &lt;li&gt;Add uggettext everywhere (easy)&lt;/li&gt;
  &lt;li&gt;UTF-8 some files.  If I had thought about this one in advance it really would have decreased my setup time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have so far written some middleware and a request context function to make everything that much easier. There is some database stuff left to do, so articles can be available in multiple languages, and possibly support for fallback.  I think for now this will be somewhat manual, however in future I do intend on creating a custom model.&lt;/p&gt;

&lt;p&gt;Once there has been some testing on this, I will publish some the code, as well as the possibility of a tutorial&lt;/p&gt;</content><author><name></name></author><summary type="html">Yesterday, I started work on using Django’s i18n to build my first multi-lingual site.</summary></entry><entry><title type="html">Replacing delete, with hidden</title><link href="https://www.djangorocks.com/2009/08/19/replacing-delete-with-hidden" rel="alternate" type="text/html" title="Replacing delete, with hidden" /><published>2009-08-19T08:55:48+00:00</published><updated>2009-08-19T08:55:48+00:00</updated><id>https://www.djangorocks.com/2009/08/19/replacing-delete-with-hidden</id><content type="html" xml:base="https://www.djangorocks.com/2009/08/19/replacing-delete-with-hidden">&lt;p&gt;One fairly common thing on a completed application is the request to hide rows from the database, rather than delete.&lt;/p&gt;

&lt;p&gt;Just today I had this problem, and this was solved in just a couple of lines.&lt;/p&gt;

&lt;p&gt;These are standard Django functions, nothing custom.&lt;/p&gt;

&lt;p&gt;My current model (for example only)&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Category&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;models&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;title&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;models&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CharField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unique&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;My new model&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Category&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;models&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;title&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;models&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CharField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unique&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;deleted&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;models&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BooleanField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;db_index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NotDeleted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;show_all&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;models&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Manager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;What is this &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NotDeleted&lt;/code&gt;?, this is where the magic happens.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;NotDeleted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;models&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Manager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_query_set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NotDeleted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_query_set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;deleted&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This will automatically append &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;deleted=False&lt;/code&gt; to your database query.&lt;/p&gt;

&lt;p&gt;If for some reason you need to get deleted items again,&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;n&quot;&gt;categories&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Category&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show_all&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;You could create a separate manager, just to show deleted items as well.&lt;/p&gt;

&lt;p&gt;For more information on Django database managers,
&lt;a href=&quot;http://docs.djangoproject.com/en/1.0/topics/db/managers/#modifying-initial-manager-querysets&quot;&gt;http://docs.djangoproject.com/en/1.0/topics/db/managers/#modifying-initial-manager-querysets&lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">One fairly common thing on a completed application is the request to hide rows from the database, rather than delete.</summary></entry></feed>