Django love
So the coding is going well these days. It better be since the deadline is in…. hmm… less then 48 hours :)
Django is an amazing framework. I am amazed with all the features that are built-in and most importantly all the features that HAVEN’T been included.
I don’t buy the whole MVT propaganda (at least I find myself coding so much stuff in the V that I feel there must be a better way to do things. Maybe some more things can be abstracted away? (For example how come I have to manually check request.POST and request.GET and do the page logic with if else statements? )
As it stands though, the tools are there to make the web developer’s life very pleasant. Instead of getting results from the database you “get” them from their class like Examples.objects.get(id=3) which in turn translates to a SELECT * from examples_example WHERE id=3;. It gets better than this, especially with complex relationships, backlinks and searching. I’d say the model part is BEAUTIFUL.
The templating language, for which I had reservations originally turns out to be very usable and user friendly. I would suggest you read through (or print) the documentation so you know what is available. There are all the basic tags you would expect but also some really neat ones that save you a lot of time. Everything is well thought out (a little confusing about when to use {% tag %} and {{ tag }}, but you get used to the syntax after like…. 15 minutes :).
One of the design cornerstones is the template inheritance system. The logic is that every template should define blocks in itself to be replaced by more specific code and also inherit the look and feel from some more general template if appropriate.
For example, if you have an book catalog website you could have the following templates.
base.html (defines the header, and general page strucutre)
profile.html (a user profile page)
profile_settings.html (some specific block of code on the profile page)
In general, if you find yourself typing something more than once you (violating DRY) you should abstract it away into a parent template and make your two pages inherit from it.
The only thing I am still not decided upon is where is the juste-milieu between {% extends … %} in a child and the {% include … %} from a parent approaches. I use both of them.
I just found a really neat way to do breadcrumbs in a django site. It is so beautiful! I had been writing my own routine for this, but I figured there must be a simpler way to do things.
What could be simpler than 0 lines of code ?