DjangoCon 2015 notes

Here is a quick set of notes from my recent trip to DangoCon Europe 2015.

 

Coding talk

There was a bit of discussion about best place to put your app’s business logic – either in the django-recommended model manager or in a service layer component

Either way never write to a model field or call save() directly in a view – a good blog post on why: http://www.dabapps.com/blog/django-models-and-encapsulation/

git-crypt might be worth a look if you ever want to store secrets in github.

Suggested preference to import models over classes and remove unneeded labelling in the process
e.g. favouring

import view
view.Login(...)

over

from view import LoginView
LoginView(...)

Lots of talk around Django as headless server & Microservices architecture – see Martin Fowler’s recent blog post on the subject: http://martinfowler.com/bliki/MonolithFirst.html

 

Python 3 talk

Probably worth always adding following imports when creating new python files:
from __future__ import absolute_import, division, print_function

And this neat utility:

pip install caniusepython3
caniusepython3 -r requirements.txt

 

Testing talk

Check out hypothesis – a nice python-based fuzz tester for unit tests

Nose is dead, long live py.test! py.test is actively maintained, has nicer output, more pythonic assert statements, ability to tag slow tests and rerun only failing tests. Will work with Django’s TestClient but might need to do some work to migrate existing nose tests.

django-test-plus – a nice wrapper around reverse and other useful utils

 

Services talk

https://requires.io/ – monitors your requirements.txt for updated packages and security fixes. Free to public github repos.

https://pusher.com/ – aims to fill the middle ground between Sentry and NewRelic