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.
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!
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Actually I would install virtualenv in the canonical way:
And just because on my system virtualenv.py from github fails!
This comment has been deleted
Problem solved Installed it the canonical way. Thanks
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.
@ernesto.troiano +1 for identifying problem and a working solution!
@klimatima: Simply clone your git repo so you have the code on your droplet.
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
@mtufekyapan: What do you mean? Do you have a webserver running?
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?
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.