Dark Light

One of the concepts you may run into if you read into Python and its fans in great depth (and here I mean Python of the programming type rather than the Monty type) is that of “Guido’s Time Machine”, the number of times when you are thinking “Would it be nice if Python did this…” and you suddenly find that yes, that’s exactly how Python does it, to the point where the only way Guido could have possibly considered all this would be if he already knew.

I’m having the same kind of thing with Django. Frameworks for validation, existing user system, that kind of thing. Stuff like “Do you know what would be nice? If I could do something so that my Logged in User’s Profile appeared in the default scope of a template, so I didn’t have to pass it in every time, and keep throwing it around the program.” and suddenly, there are Context Processors.

The annoying bits are where stuff is under development, or half documented. For example, Having spent a while creating a User Profile system to associate information specific to this system (Authentication code, invite code, email me alerts, for example) and joined it one-to-one with the user system, I then find a tiny little bit of text in the User Auth system docs which says:

get_profile() -- Returns a site-specific profile for this user. Raises django.contrib.auth.models.SiteProfileNotAvailable if the current site doesn't allow profiles.

This sound really close to what I’ve spend a while doing myself, but that is the first, last and only reference to it in the docs that I can find.

OTOH, I’ve now got a system you can log into and register for, and I’ve got a deeper understanding of how Django works. Yay.

Related Posts