View centric design with Django
I'm relatively 开发者_如何学JAVAnew to Django and I'm designing a website that primarily needs usability experience, speaking of optimized CSS, HTML5 and UI stuff.
It's very easy to use Django for data/Model centric design. Just designing a couple of Python classes and ./manage.py syncdb
- there's your Model.
But I'm dealing with a significant amount of View centric challenges. (Different user classes, different tasks, different design challenges.)
The official Django tutorial cursorily goes through using a "Template".
Is there any Design centric guide for Django, or a set of Templates that are ready and useable? I don't want to start from scratch using JS, HTML5, Ajax and everything. From the Model layer perspective Django is very rapid and delivering a working base system. I wonder whether there's something like that for the Views.
Probably django-blocks (http://code.google.com/p/django-blocks/) is aiming a bit into this direction! But otherwise I guess your only choice is to assort to some other 3rdparty html/css + js/aja frameworks depending on the functionality you need! There are also some snippets out, that implement templatetags that output common used html, but nothing big in general!
Is there any Design centric guide for Django, or a set of Templates that are ready and useable?
Django templates alone aren't that much reusable, since their are tied to specific views and variables defined in that views. In my personal experience, I found templating still rapid with an average size of my templates around 50 lines. Of course, this application wasn't heavy on the UI.
Inheritance and fragments will save you from repetition.
Inheritance:
{% extends base.html %}
Fragments:
{% for location in locations %} {% include "_location_item.html" %} {% endfor %}
I don't want to start from scratch using JS, HTML5, Ajax and everything.
Well, at a point, you'll start from scratch.
- Version-control your project, so you could extract intermediate states for the coming project, if appropriate,
- use efficient libraries like jQuery to write less, and do more,
- use some CSS scaffolding tool like blueprintcss.
I agree that there is an overhead at the beginning of a project. My justification of that overhead so far has been the fact, that the UI wasn't a modified template (like modified typo3 or so templates, hence more tailored to the applications needs), that it was fast and looked good in the end, too.
精彩评论