I took the train from Utrecht (NL) to Warsaw today. I only had to change in Amersfoort (NL) and Berlin (DE), so it was a pretty direct connection. 12 hours of train time (which I enjoy). So that’s enough time to read through two scoops of Django, the Django book by Daniel Greenfeld and Audrey Roy! Here’s my review.
The summary: buy the book and learn a lot. For the longer version, I’ll simply go though my notes I made for each chapter.
from .models import SomeModel”). That’s what’s good about this book: Daniel and Audrey state preferences and tell you best practices and sometimes those best practices won’t be your best practices. Or you didn’t know something. Anyway, it gets you thinking; which is good and enjoyable.
settings/directory, so mayhap I looked at an older beta version of the book :-)
reinout_dev.pyand so looks OK. I use a different setup and this proposed one looks better. Half the chapter is about enviroment variables as a means of keeping things like
SECRET_KEYand database passwords out of the settings. Yep, that can work. My opinion is that you can also keep it in the settings, provided you keep your code non-public. If you use environment settings, you still need to store the data somewhere. You won’t type it in by hand, will you? There’s no real suggestion in the chapter to solve this, though the solution of course depends on your chosen setup (and there are too many different kinds of setups to provide a single right answer). Nice touch is the clean suggested
ImproperlyConfigurederror when a enviroment variable is missing, this shows the care that went into the book.
auto_now_addon DateTimeFields! That’s what I read books like this for: getting hints like this.
views.py. And I ought to look at django-braces for handy Class Based View mixins.
POSTand stuff it in some query… Why not use a small form, just for the form validation? Much safer that way and I’d use more of what Django gives me! Again something in the book that educates me :-)
TEMPLATE_STRING_IF_INVALIDis handier than I thought for template debugging as you can add a
%sto the string, which shows you the failed expression. This tip is going to help a lot.
tests.pyfile and replace it with a
tests/subdirectory full of test files is correct.
logger.exception('Something went wrong'), as it logs the message at ERROR level and automatically includes the traceback. No more weird
exc_info-like stuff, just
I’ve got one big gripe with the book. There’s probably a good reason for the
omission, but I’m missing
setup.py. Telling to use a certain
requirements.txt in some
README is a poor substitute for Python’s
automatic dependency handling. This is not only good for apps you want to put
on PYPI, but also for your own packages.
All in all: valuable book, buy it!
Daniel and Audrey are at Djangocon in Warsaw, so if you’re there say them “hi” to thank them for the book.
My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.
Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):