djangosnippets.org: Latest snippets posted by Vhttp://djangosnippets.org/users/V/2009-05-25T03:01:17.971897-05:00VStaticField for non-changing text data in forms
2009-05-25T03:01:17.971897-05:00Vhttp://djangosnippets.org/snippets/1523/<p>This Field, Widget and the three lines of code in the form's clean method allow an easy (and hopefully general) way to add simple, unchangable text to a form.</p>
<p>Example use:</p>
<pre><code>class OnlyTextForm(forms.ModelForm):
points = StaticField(label=_('Points'))
reviewer = StaticField(label=_('Reviewer'))
def clean(self):
for name, field in self.fields.items():
if isinstance(field, StaticField):
self.cleaned_data.update({name: …</code></pre>
Freely redistributablegetting the related entries with a templatetag using django-tagging
2009-02-15T15:19:17.339967-06:00Vhttp://djangosnippets.org/snippets/1325/<p>Django tagging by default doesn't provide a templatetag to get the related objects for another object. Even though this is implemented as a model. Still, one can use the existing templatetags to achieve the same outcome.</p>
<p>Of course, writing a custom templatetag would be more efficient in terms of database …</p>
Freely redistributablefeedburner middleware
2008-09-23T15:43:11.817049-05:00Vhttp://djangosnippets.org/snippets/1081/<p>This middleware redirects the request for yoursite.com/feed/whatever/onefeed to your feedburner <em>onefeed</em> feed.</p>
<p>Having
<code>FEEDBURNER = ('SomeName', ('blog', 'comments', 'tag1'))</code>
will use the feedburner feeds at
http://feedproxy.google.com/SomeName/blog
http://feedproxy.google.com/SomeName/comments
http://feedproxy.google.com/SomeName/tag/tag1</p>
<p>you can add more tags, or even intersection and union of them the same way</p>
<p>(thanks to piranha for the idea of …</p>
Freely redistributableFixture for test users
2008-09-05T12:09:54.812761-05:00Vhttp://djangosnippets.org/snippets/1029/<p>This is a simple fixture that is useful for many tests.</p>
<p>It contains the following users:
<em> admin
</em> staff
<em> user0
</em> user1
<em> user2
</em> user3
<em> inactive0
</em> inactive1</p>
<p>The password of every user is the same as his username, e.g.: admin/admin</p>
Freely redistributable