Tag Archives: snippet

Django random object manager

Several times in the past I needed to fetch a list of random objects. And Today I decided to make a Mixin class to add a get_random() method to my managers: # -*- coding: utf-8 -*- from random import sample … Continue reading

Posted in django, en, Python | Tagged , , | 3 Comments

Add ‘error’ class to widgets with errors in Django Forms

Many times UI requires us to style differently widgets that have errors in a field instead or next to an error message. Django provides a nifty .errors attribute to tell if a field of form has errors but you can’t … Continue reading

Posted in css, django, web | Tagged , , , | 2 Comments

Django cheap pages

Sometimes I end up using Django for the wrong thing, just to dispatch pages and put all my content in the templates. Flatpages are too flat and other DB based content tools are too complex. I just want to use … Continue reading

Posted in django, en, geek, programacion, web | Tagged , , , | Leave a comment