background preloader

Snippets / tips

Facebook Twitter

Hidden field in Django Model. XML tabledump to model. Where is Django's blog application? In terms of people looking for sample code or example applications to use/learn from, “where can I find a good Django-powered blogging application” is probably at the top of the frequently-asked questions list both on django-users and in the IRC; part of this is simply that, right now, there is no “definitive” Django blogging application; there are a bunch of them available if you go looking, but you’re not likely to get anyone to recommend one of them as “the” Django blogging app (unless the person doing the recommending happens to be the author of one of them).

Where is Django's blog application?

In a larger sense, though, I think there’s a big gap between what people want/expect/look for from a Django-based blog and what feels “natural” to do in Django, and that gap is probably the reason why there isn’t — and may never be — a definitive Django blogging application. How I built this site. Django tips: extending the User model.

One of Django‘s great strengths is its built-in user and authentication system; the bundled application django.contrib.auth includes models for users, user groups and permissions and views for logging users in and out and changing and resetting their passwords.

Django tips: extending the User model

This is enough to cover the needs of a huge number of sites and, after the admin, the auth system is probably the most popular bundled application Django ships (or maybe the other way around, since the admin requires the auth system to be installed). Because of the auth system’s popularity, though, one of the most common questions people ask about Django is “how do I extend the User model?” By default, users have a small but useful set of fields which take care of most common use cases, but there are plenty of times where it’d be extremely handy to be able to add just a few more to suit a particular application’s needs.

There are a few immediately obvious ways to do this: Let’s extend the User model. Get/List model fields. Django: Get model from string.