Category Archives: Programming

Programming

My Vim Configuration

I have been using vim for a few years now and had been using my very own vim configuration, mainly with Nerdtree and CtrlP, in the past few days I have discovered a well packaged vim configuration with lots of plugins. But shortly I discovered that the tab space is set to 2, which I… Read More »

Django CMS Haystack 2.0 Search Index

Currently django-cms-search doesn’t support haystack 2.0 yet, so here is my modified version to work on haystack 2.0 based on

Proper way to re-user mongodb connection in node.js

I tried searching on the web and found no obvious code samples of how reuse the mongodb.connection object. This is what I have currently and hopefully the following snippet would help you out as well. If you do not think this is the right way, please leave a comment.

Django admin UnicodeEncodeError

Don’t we all get confused by unicode encoding sometimes? Especially you wouldn’t expect this kind of error to happen in django admin. The problem is actually not in the admin section, the culprit is __unicode__ method in your model. when you have a unicode function like this:

It is actually returning a ASCII string(which… Read More »

Django custom user model in admin, relation “auth_user” does not exist

I have a custom user model as below:

And using the builtin UserAdmin

While editing the user record works fine, but when I add a user, I get the following error

After some digging around and found this https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#custom-users-and-the-built-in-auth-forms The culprit is a function clean_uesrname inside UserCreationForm inside django.contrib.auth.forms.py A few tickets… Read More »

Javascript Snippet: Play next video

There is a requirement from one of my project to insert video ads before the actual video gets played. There are ways to do it, one is to use JWPlayer and OVA plugin, or the other way is to write your own javascript to control the playback. In the following demo, shows how you can… Read More »

Useful Django Apps – TinyMCE & File Browser

TinyMCE https://code.google.com/p/django-tinymce/ Want to add WYSIWYG editor to your TextFields? This app will sort you right out, basically this app will provide a HTMLField for you to use instead of just plain TextField and it will automatically render a rich text editor for you. It does require some basic configuration, here is a sample config in… Read More »