Django gotchas - part 2

Continuing with my posts on Django gotchas, this article is devoted to writing your custom authentication module. There are plenty articles out there (like this and this) dealing with this topic and even the wonderful Django documentation explains how to do it very well. However I wasn’t able to find an article that dealt with my problem specifically although most were close enough to get me going.

The problem I faced can be described in very simple terms:

  1. I was working with a legacy DB that had its own users table, i.e. I need to make use of the legacy user model
  2. The DB admin didn’t want to add tables to the DB unless it was absolutely necessary
  3. I wanted to reuse as much Django code as possible, i.e. use the auth decorators if possible as well as contrib.sessions and the corresponding middleware

Credit goes to the articles mentioned above as they all served as inspiration as well as a friendly chap, who goes by the name claudiu in #django, who not only tried a few things himself but also engaged in discussion several times.

Continue Reading »

Django gotchas - part 1

During the last month I’ve been immersed in Django almost full time in my job (almost as I had a small glitch in which I had to develop a C# application for a PDA). During this last month I came across several, as I call them, Django gotchas and I will try to document them here.

I believe it is worth writing about them as:

  1. The writings will serve as a memory aid for me later on
  2. I’ve seen too many people asking the same question over and over in #django

Gotcha #1

In the project I worked on I came across the need to chain two ChoiceField(). That is, given a particular choice selected in a ChoiceField() the choices in a second ChoiceField() would change. This is the oh-so-ever-spoken-about chain of select widgets. Nothing fancy really yet tricky enough to warrant some self-promotion here.

However before we move on …

BIG FAT DISCLAIMER: I’m still very new to Django so if anything expressed below is blatantly wrong feel free to correct me and even sue me. Now that we got that out of the way let’s move on.

Continue Reading »

Good news

In my job I have been learning and programming in C# for the past 4 weeks. It’s been sort of … interesting let’s say. My main task was to enhance/improve/fix an in-house application used mainly for logging support jobs (I work for a company that does IT support) however it has the capabilities of managing clients, their contracts, etc. Nothing to set the world on fire.

This application is written entirely in C# and using WindowsForms. During the past 4 weeks I’ve had the pleasure to work in Visual Studio and to try catching bugs in .NET’s own threaded environment (with the addition of a database query manager which adds yet a few other threads). It proved to be challenging as I was doing real work while learning the quirks and gotchas of not only the language itself (see what I said about C# scopes and why Python’s forcing of indentation is good) but the whole .NET framework.

But no more.

Continue Reading »