djangosnippets.org: Latest snippets tagged with 'primary-key'https://djangosnippets.org/tags/primary-key/2017-08-22T07:08:37.450955-05:00Compact primary keys
2017-08-22T07:08:37.450955-05:00bernd-wechnerhttps://djangosnippets.org/snippets/10620/<p>If the primary key on a table is an integer, it can be desirable after a lot of adding and removing either during testing (as was my case) or otherwise, to tidy up the key space a little and see the primary keys run up as unbroken sequences from 1. …</p>
Freely redistributableupdate primary key (cascade to child tables and inherited models)
2013-05-01T03:46:47.274839-05:00varianthttps://djangosnippets.org/snippets/2915/<p>An improvement to the excellent snippet by guettli <a href="http://djangosnippets.org/snippets/2691/">http://djangosnippets.org/snippets/2691/</a></p>
<p>Added support for cascading relations when using model inheritance.</p>
Freely redistributableupdate primary key (and cascade to child tables)
2012-02-22T06:58:53.558080-06:00guettlihttps://djangosnippets.org/snippets/2691/<p>Management command to update a primary key and update all child-tables with a foreign key to this table.</p>
Freely redistributableRandom object IDs using an abstract base model
2011-07-15T06:25:15.057845-05:00elverhttps://djangosnippets.org/snippets/2490/<p>To put obfuscated primary keys in any class, simply inherit from this one. For example:</p>
<p>class Offer(ObfuscatedPKModel)</p>
<p>You can match for these bigint primary keys in your urls.py like this:</p>
<p>'^offer/(?P<offer_pk>[0-9-]+)$'</p>
Freely redistributableModel with random ID
2008-06-18T14:22:24.562778-05:00jobs@flowgram.comhttps://djangosnippets.org/snippets/814/<p>An abstract model base class that gives your models a random base-32 string ID. This can be useful in many ways. Requires a Django version recent enough to support model inheritance.</p>
Freely redistributable