Login

Snippets by V

Snippet List

StaticField for non-changing text data in forms

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. Example use: 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: self.initial[name]}) return self.cleaned_data

  • forms
  • field
  • widget
Read More
Author: V
  • 1
  • 2

getting the related entries with a templatetag using django-tagging

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. Of course, writing a custom templatetag would be more efficient in terms of database access.

  • templatetag
  • tagging
  • related
  • django-tagging
Read More
Author: V
  • 0
  • 2

feedburner middleware

This middleware redirects the request for yoursite.com/feed/whatever/onefeed to your feedburner *onefeed* feed. Having ``FEEDBURNER = ('SomeName', ('blog', 'comments', 'tag1'))`` 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 you can add more tags, or even intersection and union of them the same way (thanks to piranha for the idea of a middleware) **Update:** now it works for tags as well

  • middleware
  • feedburner
Read More
Author: V
  • 3
  • 10

Fixture for test users

This is a simple fixture that is useful for many tests. It contains the following users: * admin * staff * user0 * user1 * user2 * user3 * inactive0 * inactive1 The password of every user is the same as his username, e.g.: admin/admin

  • testing
  • fixtures
  • auth
  • test
  • fixture
  • users
Read More
Author: V
  • 3
  • 3

V has posted 4 snippets.