djangosnippets.org: Latest snippets tagged with 'abstract'https://djangosnippets.org/tags/abstract/2012-05-15T11:25:45.770359-05:00Binding signals to abstract models
2012-05-15T11:25:45.770359-05:00andreterrahttps://djangosnippets.org/snippets/2749/<h2>Intro</h2>
<p>I found a question on SO for which Justin Lilly's answer was correct but not as thorough as I'd like, so I ended up working on a simple snippet that shows how to bind signals at runtime, which is nifty when you want to bind signals to an abstract …</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 redistributableCustom optional abstract base attributes
2008-06-16T18:58:19.484147-05:00tiehttps://djangosnippets.org/snippets/809/<p>I needed an abstract base class that can add attributes to the child classes based on the child's name. The attributes had to be implicit, but overridable, so all derived classes would get them by default, but they could be easily overriden in the child definition.</p>
<p>So, the code code …</p>
Freely redistributable