0
1

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.

asked 12 Mar '12, 17:09

tharyn13's gravatar image

tharyn13
12
accept rate: 0%

edited 12 Mar '12, 18:02


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.

You should rely on our official docs and the Django offical docs while learning, your question for how to install things is answered in full there.

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.

link

answered 12 Mar '12, 19:08

johns's gravatar image

johns ♦♦
4.1k28
accept rate: 23%

edited 12 Mar '12, 19:13

Thank you for the comprehensive response! I'll got through some more docs, but I'm still very confused about the difference between my local env and webfaction's env. My code does not work on webfaction because many minor settings are different. So then I have to edit all these little things, but now the original project won't run locally. How can I eliminate this dilemma?

(13 Mar '12, 09:09) tharyn13 tharyn13's gravatar image

You could try adding a conditional statement, an if for example, that checks the hostname and acts accordingly. If its running on the server a function like gethostname should return something similar to 'webXXX.webfaction.com'.

This is a quick and popular hack if there is a small amount of minor changes, but it does get difficult to manage if there's more to it, where virtualenv really helps.

(13 Mar '12, 09:25) iliasr ♦♦ iliasr's gravatar image

Also, if you are talking about sys.path issues, those are normal for all new Django devs to struggle with. The reason is the devserver is a simple python based program designed to let you easily test code, but not designed to multi-task or serve a live site. Because they are more complex and do more work they have more configuration options. Researching how python path works will help make that part of Django/Apache/mod_Wsgi make more sense.

(13 Mar '12, 17:32) johns ♦♦ johns's gravatar image

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:

http://www.djangobook.com/en/2.0/

https://docs.djangoproject.com/en/1.3/

link

answered 13 Mar '12, 03:30

markusbarth's gravatar image

markusbarth
112
accept rate: 0%

Thanks! I'll keep an eye out for that once you're done. I've heard great things about firebug, so I'll check it out.

(13 Mar '12, 09:00) tharyn13 tharyn13's gravatar image

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.

link

answered 13 Mar '12, 15:55

wolfpaw's gravatar image

wolfpaw
1
accept rate: 0%

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.

link

answered 13 Mar '12, 23:20

markusbarth's gravatar image

markusbarth
112
accept rate: 0%

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.

link

answered 14 Mar '12, 02:07

laserlight's gravatar image

laserlight
1
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×742
×170
×34
×8
×1

Asked: 12 Mar '12, 17:09

Seen: 1,870 times

Last updated: 14 Mar '12, 02:07

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited