Django redirect on duplicate object creation
So I had this project with a peculiar requirement: It had to do a redirect to an existing object when the CreateView failed because such an object already existed in the db. Not really hard to do but it took me a while to figure out.. so here's the code. more
Script to migrate WordPress plugins from SVN to github
Update: This script is almost obsolete as github will switch to their v3 API on may 1st, 2012 and doesn't display the API token any more... With this this script you can easily migrate a WordPress plugin from the wordpress.org svn repository to github. This script will NOT import the ... more
No suitable request handler found
Very annoying typo3 "bug" and it took me long to find a solution. See this Bug report for some more info. more
Redirect or block hotlinked files with nginx
Hotlinking is always annoying, but easy to prevent. Here are two ways to do this with nginx. The first example simply returns a 405 when any hotlinking is detected. The second example prevents hotlinking only from specific domains. I used this when a site tried to embed media files through ... more
Debian init script for virtualenv'd gunicorn_django
I recently moved my projects from wsgi to gunicorn and needed init scripts. Here's what I'm currently using. I have the gunicorns running behind nginx, so you might want to tweak the IP and PORT settings. It might also be nice to use start-stop-daemon. more
Django query on model instance's class
I have an abstract base class that is used by various other models. The problem is that I need the same method that runs a query on all instances of those models, and that the manager isn't accessible via model instances. This is the code I ended up using. more
Set static front page and blog page programmatically in WordPress
You want to make sure the About and Blog pages exist, so create them before if necessary, see wp_insert_post() more
Custom WordPress SQL query for multiple meta values
To check for multiple custom fields you have to join the meta table twice. more
Run code when a new blog is created
Run some code when a new blog is created. I'm not sure, but I guess this code has to be in a network-activated or mu-plugins plugin. Maybe having this code enabled in the blog you're using will suffice. more
I am Nicolas Kuttler, a web developer, system administrator and IT consultant from France, currently living in Germany.