Django is a Web framework written in Python that is designed to help build complex Web applications easily by reusing common code.
These instructions are designed to cover the specifics of setting up Django on our servers. Since we run a shared hosting environment that doesn’t provide mod_python or root access, this guide will explain how to install and configure Django to run via FastCGI in a Virtual Python environment. Please be sure to consult the Django documentation for any further information.
Please note that Django is an advanced software package that is targeted at Web developers who are familiar with the Python programming language and comfortable with the command-line shell. We can’t provide support for custom Python scripts or versions. If you’re looking for a content management system for your website that is extendable and easy to manage, you may want to consider WordPress instead.
1. Install Python virtualenv
You’ll need to setup a “Virtual Python” installation, called a virtualenv. This will allow you to install additional Python modules without requiring “root” access.
First, you’ll need to find the current link to download virtualenv. To do this, visit the virtualenv download page and look for the source package (named something like “virtualenv-15.1.0.tar.gz”). Then your browser’s Copy Link Address feature to get the full long URL.
Then login to the shell and run the following commands from your home directory, replacing the first line with the URL you copied:
This installs a private version of Python in a directory called “private-python”. Update your $PATH variable to use this private version by running this command:
To reload your bash_profile and verify that the change has taken effect, run the following commands:
It should display “/home/ex/example.com/private-python/bin/python”.
By the way, the instructions above are simply a version of the more detailed instructions on the virtualenv installation page. if you have any trouble, you should consult the “To use locally from source” section of that page.
2. Installing extra modules
Before creating your first Django site, you need to install at least one additional Python module called “flup”. Flup is a Python utility for FastCGI enabled sites. As mentioned above, our servers don’t use mod_python, so FastCGI is used to run python scripts. You can install this package by running the following command:
Now you are ready to install Django.
3. Get Django
To get the latest stable version of Django, run this command:
You can verify Django is installed by running the following command:
If everything is working properly, this will print the Django version, such as “1.6.5”.
Django is now successfully installed on your account and you can start setting up projects. Below are instructions for creating a very simple test site, giving an idea of how to manage Django projects on our servers.
4. Creating a test site
Django developers recommend keeping the code for your sites outside of your main Web directory, so users aren’t able to view any sensitive information that may be contained within your project. Create a “projects” folder in your home directory to store your projects:
This creates a directory at “
Now you will create a subdomain in your Web folder which will let you access the project via a Web browser:
Then switch to that folder:
Now you need to create a FastCGI script to run this project. Using a text editor, create a file called “dispatch.fcgi” that contains the following code:
Once you have saved this file, make sure it has the correct permissions by running:
Now create a .htaccess file in this folder with the following code inside:
5. Using a database
If you plan to use Django’s database API functionality, you’ll need to create a MySQL database. We recommend creating a new database specifically for each Django project, rather than using an existing one. To create the database on our servers, follow our instructions explaining how to create a MySQL database.
6. Final notes
Managing sites with Django can be a complicated task that goes well beyond the scope of our support. For any questions regarding the use of this software, please see the official Django documentation for more detailed information and support.
Copyright © 2000-2020 Tiger Technologies LLC