I sat down and wrote my first Django app (in a very long time) yesterday using this tutorial, parts 1-3. Here’s some stuff I thought and learned:
- Django has amazingly good documentation. That tutorial is fantastically written, clear and concise and elaborating where necessary. And an actively interesting toy app, it’s not just a dumb toy.
- The polish is very good. Everything worked just as described with no weirdness. I particularly like that sqlite was the default database, that’s the right place to start for learning.
- The distinction between a “project” and an “application”seems like needless complexity. The theory is that a single Django project instance might contain a mix of several independent applications. I wonder if that’s done in practice? I suppose so right away, the default project has the admin, auth, contenttypes, sessions, messages, and staticfiles projects. I wonder if many Django projects contain multiple third party / homegrown applications?
- If you use the wizard to make an application and a project you end up with 12 files and 185 lines of text. I’m not a fan of codegen, it usually betrays an unpleasant complexity, but it’s not too bad in this case. The only big file is settings.py and that’s basically a declarative setting of what’s included in the project. That’s gotta go somewhere.
- The good thing about Django is it comes with its own ORM and HTML template system. The bad thing is end up using their ORM and HTML templates. I don’t have enough experience with them to have an opinion other than some initial crankypants reactions.
- The data model / migration / database agnostic stuff is pretty slick. I wonder if it works in practice.
- I hate choosing between CamelCase and underscore_separation and forcedlowercase. The latter is particularly alarming; my database table names seem to be coerced downcase. Perhaps that’s a compatibility thing?
- The auto-reloading of code is nice.
- It appears that Django has no favored CSS UI framework. I imagine it’s easy to drop in Bootstrap or whatever, but part of me was hoping for some default styles that would make it easy to make things that look OK.
I ended up having 7 files open in my editor
- project/settings.py to register my app
- project/urls.py to register my app’s urls,
- app/admin.py to register my models
- app/models.py to define my data model
- app/urls.py to define my webapp URLs
- app/views.py to define my webapp views in response to URLs
- app/templates/app/index.html as an HTML template for my view
Those first three files feel like make-work but the other four are actual real code I care about. That’s pretty good!
Overall I’m pretty pleased so far. I already know the pitfalls of going down this road, the way an ORM can betray you on performance in heavy traffic situations. But that’s not a road I’m worried about right now, and if I do ever get there I’m guessing there are ways to build
special hacks bridges around the ORM overhead.