Defying Classification

by Malcolm Tredinnick

Topic: software/django/tutorials

Mon 3 Jul 2006

Django Tips: Forms With Multiple Inline Objects

Posted at 23:38 +1000 (edited 16 Sep 2006, 12:57)

The form creation and handling code in Django seems to strike a nice balance between "making the easy things easy and the hard things possible", as the saying goes. However, there are some areas of it that are not perfectly documented yet and sometimes you have to rummage through the source code for a few minutes to work how to achieve something that, in retrospect, is simple.

One example: how to create a form for editing multiple inline objects on a single page?

The admin interface manages this fairly nicely for relatively small numbers of objects. Surely it should be possible to do the same in our own, customised forms. It is indeed possible and not too difficult, either...

(Read more...)

Topics: software/django/tips, software/django/tutorials

Thu 29 Jun 2006

Django Tips: Extending Generic Views

Posted at 01:16 +1000 (edited 16 Sep 2006, 12:57)

James Bennett has started what I hope might be a series of Django tips today. Should become required reading for Django users, I suspect. So let's help the guy out a bit here. With any luck, we won't duplicate each other's work.

One thing that keeps coming up again and again on #django on IRC, the mailing list and in the Django bug tracker are requests for some small customisation to generic views to accommodate some particular use-case. In almost every case — I would say, in every case, but I am sure there are exceptions that I haven't seen yet — these cases can be handled with only a few lines of code and then passing off the bulk of the work to the generic views.

(Read more...)

Topics: software/django/tips, software/django/tutorials

Wed 14 Jun 2006

Custom SQL In Django

Posted at 18:52 +1000 (edited 21 Jul 2006, 11:22)

For people wanting to write custom SQL queries for use in Django and are wondering how to make them "fit in" somehow with the rest of your code, a short tutorial follows. Requires a little bit of familiarity with Django to be useful, I suspect.

Also, if you are interested in learning more about some of the more advanced corners of Django, there are a few other people writing instructional pieces at the moment. In general, have a look at the Django aggregator for recent updates, but, in particular, I would like to draw attention to Ian Holsman's recent writeups of content types and signals as they are used in Django. Similarly, James Bennett's excellent series of posts about various useful topics are well worth your time.

And that will certainly be enough link pimping for today.

(Read more...)

Topics: software/django/tutorials