(One of the summaries of a talk at the 2015 Djangocon EU conference).
Loek Van Gent has done lots of php/zend work for many, many years. Now python/django for 3 years. He is a member of the 1% club, they support small initiatives that help change society, a “do-good crowd funding platform”.
They went from two separate sites to one site that could be used as a white label/multi-tenant site. It took quite some engineering effort. And they also made a couple of UI changes, more or less 2% of the work. The boss’s reaction? “Wow, I love the new design, great job”.
The title of his talk is “true beauty is on the inside, but users are shallow”. In this case, the boss was shallow and only looked at the the outside, even though 98% of the work was on the backend of the website.
Nothing really wrong with that. It underscores the importance of how something looks.
He demoed the creation of a django project. A site and two apps. Each app of
course has a template/
and static/
directory. But you shouldn’t do
that. At least according to the 1.8 edition of “2 scoops of django”. You
should have one place in your site for templates and static files. But we can
go even further.
Let’s look at some front-end tools:
Bower. Useful for grabbing css/javascript dependencies.
Sass. Structured css.
Grunt. Minifying and combining.
Npm. Installs all this.
It is starting to look like an entire project inside your django project. Yes! That’s it. That’s what he’s trying to say.
Why not have django with django rest framework talking to a separate front-end? The front-end can then be made with a full framework like ember or reactjs.
Some advantages:
If your server only talks through a REST API, it is easy to test the responses.
Similarly, you can start developing the front-end with a mock API instead of waiting for those developers to finish their thing.
You can deploy them both separately from each other in case that’s handy.
Summing it up:
Love your front-end. It is the only thing your users get to see! They won’t see the wonderful things you did on the backend.
Group your front-end.
Use tools to help structure your front-end code. Bower & friends. Just try them and start using them.
Use a front-end framework like ember, angular or react. (Just don’t use backbone).
My name is Reinout van Rees and I program in Python, I live in the Netherlands, I cycle recumbent bikes and I have a model railway.
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):