Django close colorbox popup

Ok I had a ton of popups with forms using colorbox and django but on successful submission they needed to be closed instead of standing around. So after some tests and trials the best way to tackle this is to create a template called closed_pop.html or something and have the view render that after a successful submission. In the template closed_pop.html should have the following code:

<script language=”javascript” type=”text/javascript”>
parent.$.fn.colorbox.close();
</script>

Done !

Django row based user permission

Went google hunting today for a decorator to manage permissions per record. Found a cool snippet here http://djangosnippets.org/snippets/874/ , modified it to work and to my particular needs, this should work on any model that has a fk pointing to User.

To use just add the following on top of your view, like so: Continue Reading

Django flag howto

I’ve had django-flag https://github.com/pinax/django-flag on my todo-list , finally got around to it and found that there was no documentation written for it.  Well no worries a quick browse through all the code in the package made it easy to figure out the workings.  Anyhow here’s how you use it !

1. Install via pip

pip install django-flag Continue Reading