kristian
kristian

Reputation: 760

How to work with a local development server and deploy to a production server in django?

I want to work locally on my django(1.7) project and regularly deploy updates to a production server. How would you do this? I have not found anything about this in the docs. I am confused about that because it seems like many people would want to do that and there should be some kind of standard solution to this. Or am I getting the whole workflow wrong?

I should note that I'm not expecting a step-by-step guide. I am just trying to understand the concept.

Upvotes: 0

Views: 1344

Answers (4)

kaleissin
kaleissin

Reputation: 1295

There is no standard way of doing this, so no, it cannot be included with Django or be thoroughly described in the docs.

If you're using a PaaS how you deploy depends on the PaaS. Ditto for a container like docker, you must follow the rules of that particular container.

If you're old-school and can ssh into a server you can rsync a snapshot of the code to the correct place after everything else is taken care of: database, ports, webserver setup etc. That's what I do, and I control stuff with bash scripts utilizing a makefile.

REMOETHOST=user@yourbox
REMOTEPATH=yourpath
REMOTE=$REMOTEHOST:$REMOTEPATH

make rsync REMOTE_URI=$REMOTE
ssh $REMOTEHOST make -C $REMOTEPATH deploy

My "deploy"-action is a monster but might be as easy as something that touches the wsgi-file used in order to reload the site. My medium complex ones cleans out stale files, run collectstatic and then reloads the site. The really complex ones creates a timestamped virtualenv, cloned database and remote code tree, a new server-setup that points to this, runs connection tests on the remote and if they succeed, switches the main site to point to the new versioned site, then emails me the version that is now in production, with the git hash and timestamp.

Upvotes: 1

joeB1
joeB1

Reputation: 71

Lots of good solutions. Heroku has a good tutorial: https://devcenter.heroku.com/articles/getting-started-with-django

Check out a general guide for deploying to multiple PaaS providers here: http://www.paascheatsheet.com

Upvotes: 0

user1631075
user1631075

Reputation: 355

Assuming you already have your deployment server setup, and all you need to do is push code to your server, then you can just use git as a form of deployment.

Digital Ocean has a good tutorial at this link https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps

Upvotes: 2

Andrew_Lvov
Andrew_Lvov

Reputation: 4668

Push sources to a git repository from a dev machine. pull sources on a production server. Restart uwsgi/whatever.

Upvotes: 1

Related Questions