Django Custom View Decorator with Arguments

To make my life easier I made a simple decorator which checks if the parameters are present in the request.POST or request.GET and returns a response if they are not.

It accepts a list of parameters in string format and will loop through each parameter to check if …

more ...

Simple function to return json in Django

Just a small code snippet I use when I need to return json, comments are welcomed.

from django.http import HttpResponse  
from django.utils import simplejson as json

def json_response(dict_to_convert_to_json):  
    return HttpResponse(json.dumps(dict_to_convert_to_json),
                        mimetype="application/json")

To use it in your view you just do it this …

more ...

Chinese New Year 2012

The Chinese New Year aka Spring Festival is the most important festival in Chinese culture. All the people travel back to their hometown, because most of them are working/studying in cities far from their own hometown. That means all train tickets are sold the day they get available and …

more ...

Importing a SQL dump in postgres

I always keep forgetting how to import a SQL dump into postgres and found it always hard to find the right documentation. So I thought lets share it:

psql -d dbname -U username -f dumpfile.sql

This should also work with files created by pgdump.

more ...




Samwich: Sam's tasty sandwiches

I went to sell sandwiches on the streets of Beijing. Why you think? Just for fun and experience. I often buy food on the streets here myself, stuff like sushi, pancakes, noodles etc and I really like it. It's quick fun and tasty. So I also wanted to do that …

more ...