Login

Tag "simple"

Snippet List

Math Captcha Field and Widget

This math captcha field and widget was inspired by Justin Quick's django-math-captcha, but I wanted to make it into one form field and not have anything in settings.py. I removed the division and modulo operators to avoid people having to input fractions, and just randomly select the operator. It leverages Django's built-in MultiValueField to set up the hidden hashed answer to compare the user's input to instead of rendering strings for the fields like django-math-captcha does. Unit tests soon to follow, but this is used in production at: http://btaylorweb.com/. Enjoy!

  • simple
  • captcha
  • field
  • widget
  • math
  • multiwidget
  • multifield
Read More

RSS feed authentication

This is a very simple way of getting authenticated RSS feeds in django, by slightly changing the django.contrib.syndication.views 1) copy django/contrib/syndication/views.py into mysite/feeds/views.py 2) replace the contents of that file with the snippet 3) any feeds which you require login just add them to the auth_required list. In this case I require login for /feeds/mystuff/ so I make auth_required = ['mystuff'] My directory structure is like this: mysite/feeds/ views.py feedmodels.py feedmodels.py is just where you make your feed models (see http://docs.djangoproject.com/en/dev/ref/contrib/syndication/ where they give an example of "LatestEntries") [urls.py] - this is what I add in urls.py from mysite.feeds.feedmodels import Latest,MyPersonalStuff feeds = { 'latest':Latest, 'mystuff':MyPersonalStuff, } (r'^feeds/(?P<url>.*)/$', 'mysite.feeds.views.feed', {'feed_dict': feeds}), ###########################################################################

  • authentication
  • feed
  • rss
  • simple
Read More

Slice filter

Handy for things such as: `{{ some_string|slice:","|join:";" }}`

  • filter
  • string
  • slice
  • simple
Read More

3 snippets posted so far.