Having done about 5 – 6 mini apps in Django now, I’m beginning to get into a sort of rhythm. One of the questions I had early on was “What is a good Django workflow”. The answers were good but kind of high level for my liking. Also, given that I’m not trained in the art of Agile Development, terms like actors, continuous integration and the like mean very little to me. Having said that however, I do understand its importance especially in the context of Lean Startupbut this is not the time for me to get involved with more jargon and complexity at this stage of my learning.

So this is my current hands-on workflow for a new Django app:

Django Workflow

Create a new project and a new app called mainapp Edit settings.py. Fix the following: Database settings Installed apps Media and media admin paths Most recently, to add CSS and JS paths Edit urls.py in the project folder and Uncomment the admin paths Include mainapp.urls.py Create a new urls.py in the mainapp folder Create a path that display a view called home Create a new templates folder Create a base.html file in the templates folder Create a place-holder variable within base.html Edit the views.py file. Create a new view called home and return ‘hello world’ using the base.html template and a place-holder variable Create a media folder the project folder (1 level up from the mainapp folder) Edit the models.py file Run syncdb At this point, you should be able to access both your admin page and your homepage that outputs ‘hello world’ by running the development server

I think this process is applicable to any new Django project and serves to get the ‘paperwork’ out of the way so you can start getting on with the actual coding within your views.py file. If you have any suggestions or if I’ve missed something out (I had to write this post twice x_x), do leave them in the comments.

Lessons Learnt

Django’s strength is also it’s weakness. It’s easy to get a new project going but changing the database structure is a pain. You can’t add new columns to an existing table in your models.py file and expect syncdb to update your database schema. This is a recgonized problem and tools such as South have been created to address this. I haven’t tried using it yet and I really ought to. I need to start looking at other Django projects to see how others layout their apps. Right now, I’m working on a reporting app for Insync ( gdocs sync ) and my views.py is very big . I’m not even sure whether others consider it to be big and that what I have is the norm. So when is a good time to split it into another app within the project is a question that is on my mind. So if you’re a Django Jedi Master looking to deposit some goodwill in my goodwill bank because today you, tomorrow me , do let me know 🙂 Think I need to start reading on the forms feature in Django. It takes care of trivial situations like this question I had — remembering a radio button selection Also need to start reading up on Django unit testing at some point.