4 ms·
I had a look at django recently. Last week actually. My advise would be to start coding. Make sure the thing is installed right and that you can talk to your da
by vikram 18y ago
I had a look at django recently. Last week actually. My advise would be to start coding. Make sure the thing is installed right and that you can talk to your database of choice and that your examples run.
Then start coding. It's not too difficult. Some of the things with template engine are a bit funny, so try and not write any big code here, move it to the view/model. But otherwise remember that google is your friend.
My app is a geo based app, but I couldn't get geodjango to play nice. So I just installed the libs and went with that.
- mrtron 18y agoThe template engine is intentionally designed so you have to move any major logic or 'business rules' to the view and out of the template. This can be a different style than other web languages in the beginning, but trust me you will be thankful in 6 months when you are adding a new feature that you don't have to touch the templates (or not much).
- vikram 18y agoI think in most cases when you add a feature you end up touching everything in each of the layers. It's only when you want to change something that it's possible that you might just be restricted to one layer. I think the idea of the template is that you have one template and many views, and possibly that a template can be created of many different smaller templates, e.g. header, footer, sidebar. Here is an example of something that I wanted to do with a very specific template that wouldn't be used on any other page. My model gives distance in meters, for each of the objects and I wanted to display it in miles. So I had to add a new method to the model dist_miles. Instead of just saying round(cinema.dist / 1600, 2) in the template. I've only been using django for a week now so its quite possible that I'm going about it all wrong.
- GrumpySimon 18y agoYep, all wrong :) You want a custom filter: http://www.djangoproject.com/documentation/templates_python/ http://www.djangoproject.com/documentation/templates_python/
- mrtron 18y agoOther types of complexity can be handled in custom template tags too. The easy way to look at them is you could write your own 'filter' or 'count' or any of the tags you see. However, most of your needs can be met by the built in filters.