Customize the Django settings.py file depending on the OS
Question: I'm working on a Django project using two different machine, a Windows and a
Mac Os X. I have everything synchronized over Dropbox. The problem is that
some settings in settings.py are single strings (e.g. the MEDIA_ROOT or the
STATIC_ROOT) and not tuples. That means that I can set a proper path for,
let's say STATIC_ROOT for only one of the two OS. In the other one of course
it won't work.

I was wondering if there exist a way to recognize the OS python is running on
and choose the proper setting through a condition according to it.


Answer: The settings.py file is just python, so you can easily switch out statements
based on the platform. Use the [`platform`
module](http://docs.python.org/library/platform.html):

    
    
    import platform
    
    if platform.system() == 'Darwin':
        MEDIA_ROOT = 'something'
    else:
        MEDIA_ROOT = 'somethingelse'
    

