Django is a free, open-source program that streamlines Python programming to help developers create “clean, pragmatic design.”
The virtual private server needs to be equipped with Python before Django can be installed. The recommended installation method is to create an isolated Python environment, called a virtualenv, where any changes made to the overall virtual server will not affect the Python projects. An additional benefit of using virtualenv is that it does not require root access to install or manage. Django itself can then be installed within the virtualenv with the help of Pip, a tool that makes installation, upgrades, and removals of Python Packages extremely easy.
You can install Pip on Ubuntu through apt-get:
- sudo apt-get install python-pip
Go ahead and install Python:
- curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
Once that process has completed, we need to create the new virtualenv.
- python virtualenv.py example_env
The next step is to activate the virtualenv so that all further changes and installations will be done only within example_env
- . example_env/bin/activate
In the previous step, we setup the environment to install Django. Now using the easy pip installer, we can get Django on our droplet.
- pip install Django
For future reference, you can use these commands to make changes to your version of Django or any other Python packages:
- pip install --upgrade Django
- pip uninstall Django
You now have Django installed on your VPS!
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Former Director of Community at DigitalOcean. Expert in cloud topics including LAMP Stack, CentOS, Ubuntu, MySQL, SSL certificates, and more.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I’m confused, are the steps under “On other systems, you can take the following steps:” on installing pip missing? Because after that it seems to point out that we need to install virtual_env, nothing about pip is mentioned.
I installed Django. I upload my django codes via ftp. Now i can see my codes but they didn’t work just see they as a file. How i can run this code on server?
hi, i installed django as per the instructions here. what further steps do i need to take in order to get my django code running from either my localhost or from my git repo (hosted on bitbucket)? can you provide me with the relevant steps to take. i have also installed git on my virtual server thanks in advance
@klimatima: Simply clone your git repo so you have the code on your droplet.
Actually I would install virtualenv in the canonical way:
sudo apt-get install python-pip
sudo apt-get install python-virtualenv
virtualenv example_env
source example_env/bin/activate
pip install Django
And just because on my system virtualenv.py from github fails!
When I try this command frans@frans-eMachines-D620:~$ python virtualenv.py example_env
I get the error message python: can’t open file ‘virtualenv.py’: [Errno 2] No such file or directory
I also had to install curl
I am sorry the solution my be obvious, but I am stumped.
This comment has been deleted
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.