Disclaimer: I am only 2 weeks old using terminal/python/django/all web dev stuff. Using Mac Lion OS
I did a few django tutorials and created an app already. Then I researched into deploying online and signed up for webfaction. My local environment is all over the place. I want to make it easy to test locally and deploy changes online in the simples way possible.
Could you tell me in lay mans terms how my local environment should look and and in what order/how I should install the items? (virtualenv, apache, git, etc...) Then what is the easiest process to push an app to webfaction.
Thanks so much for helping a newb!
PS. I already read Getting Started with Django webfaction docs, which doesn't touch on the local side of things.
What I expect you would like is a step by step guide for Django development and deployment best practices and IMO there is not one best way.
The problem is basically every Django/python developer does things very differently, asking any one of us how to do local development and than deployment will render different and valid answers.
For me, I only use a text editor with syntax highlighting, and SSH. I do all my development and deployment with those 2 tools alone, No IDE and no 'automatic' deployment solution. I just edit the text files locally, do development and than deploy. From experience alone could I tell you what a particular chunk of code would need to be integrated into a live site and database. If I ever want to edit Apache/Django/mod_wsgi I simply SSH into the account and make the changes I want in 'vim', than restart apache.
Only once you figured out exactly how to do the process with shell and a text editor alone should you attempt a more complex solution.
One alternative solution for local development is to use an IDE as opposed to a text editor, not my cup of tea, but some people like to.
One alternative for deployment once you understand how it works is to use a python tool like fabric to make an automated deployment script. You could also use git or svn and post commit hooks.
Just try out different editors, I have been using kate for a long time, now I am playing around with Ninja IDE. Use Firefox with firebug! - especially if you want to use asynchronous requests (ajax/json).
Concerning uploading, you could use any of the revision systems like svn but this would be a bit of an overkill. You can also use rsync.
Right now I am writing a python skript that keeps track of all changes within a project by means of sqlite-stored md5 checksums, makes backups and uploads of the changed files every time you run it and can run skripts on the server before and after file synching, for example to dump the database (before) or automatically restart apache (after). I'll post it here as soon as I've got it ready. (kudos to Robey Pointer for paramiko)
"The local side of things" is broadly dealt with in the django docs:
answered 13 Mar '12, 03:30
I have a seperate linux VPS server where I do my development work and testing. Then when the code is ready I just FTP the files and templates across to my "live" environment at webfaction, sync my database and that's pretty much it.
My development VPS has gnome installed with the free edition of nxserver so that I can do django in a graphical interface connecting from several different PCs (home/work etc). I use the free Komodo-Edit IDE for development work as it's pretty nice to use.
I also maintain my subversion codebase on my webfaction account too.
answered 13 Mar '12, 15:55
Concerning two different versions of settings py on devel and production server, apart from conditional statements, there is a simple way to manage this. First, make a backup of the file (just in case): cp settings.py settings.py.prod. Then, make the file read only: chmod 444. If you use an ftp client that handles failed file uploads gracefully like filezilla, you can now simply bulk-copy the whole project. However, this only works for simpler projects. As soon, as there is more data you don't want to copy to the server (test data in the upload folders, etc.) you need to look for a better solution.
answered 13 Mar '12, 23:20
If you have a worry about configuration settings being different, then look into the use of a local_settings.py that is imported into your settings.py
This way, minor variations in the settings are determined by differences in local_settings.py, which is not under version control.
answered 14 Mar '12, 02:07