Python – How to prepare a django project for future changes


As I work on my first django powered site, I am constantly learning new things and making all sorts of changes and additions to my apps as I go. I try to follow DRY and pythonic principles and be smart in my coding but eventually I will have to take the site live and am certain that not long after I do, something new and exiting will come down the pipe and I will want to implement it.

Preparing for the future:

With this in mind, do folks have any suggestions about how I can prepare my code now to be as future-ready as possible for these currently unforseen/unknown upgrades/additions to my code base?

Hindsight is 20/20:

What do you wish you had done at the start that would have made your life easier now that your site is up and running ?

Little Things I've Learned (examples):

  • use UTC as the default timezone (and use datetime.datetime.utcnow())
  • use South to aid future database changes (haven't done it yet, but it seems wise)
  • not hard code links in my templates (use get_absolute_url() and reverse lookups)
  • create a separate tools app to contain small re-usable templatetags and utility functions that I may want to use in future projects (no need to decouple them later)

These are small tips, and some straight from the django-docs, but I think they help .

How about you? What are your best practices for a new app or project that prepare you for the future?

Best Solution

  • Deploy into a pure environment using virtualenv.
  • Document requirements using a pip requirements file.

I'm sure others will suggest their deployment strategies, but making these changes were big positives for me.

Related Question