Login

Snippets by jorjun

Snippet List

Better Django Model Field Choices

Nice to name your constant multiple choice fields in models, this is one way of doing that. Sorry I haven't looked into existing alternatives. But this approach worked for me.

  • choice
  • choices
  • model
  • field
Read More

Redirect view based on GEO

Wanted a neat way to redirect views based on GeoIP determined criteria, from HTTP_REFERER. Decorator approach seemed the best way to make it straightforward to redirect views. To use, installed the Max Mind Python GeoIP API : http://www.maxmind.com/app/python

  • view
  • redirect
  • geoip
Read More

Automating URLs

This might be a bit cludgy. But the idea is to extend model definition with mixins that can help with defining standard views. So defining a new model as inheriting from Model and All, would allow automatic definition of /get /post type accessors.

  • rest
  • url
Read More

jorjun has posted 3 snippets.