Installing Django can be made easy by following this article, allowing you to get started quickly. However, it's important to note that the installation process is only the first step, as additional custom configuration on the server is necessary for the framework to function fully.
InMotion Solutions or Advanced Product Support (APS) will not be able to provide help with this configuration, so if you want to use Django, you should either have a developer on hand or be familiar with using it yourself. While the installation itself is straightforward, utilizing Django effectively does require developer knowledge.
This article will explain the process to install Django on a VPS or Dedicated server.
Install Django
IMPORTANT: This solution may require root access. If this needs to be obtained, follow the guide on requesting root access.
NOTE: Root is not required to install Django, but a VPS or Dedicated Server is needed because of all the other configurations that need to be done for Django to run properly, such as opening ports, installing Python and Apache modules, etc. Additionally, If you require one of the 2.0 versions, then you will need to use InMotion Solutions.
- Access your server via SSH using the Terminal in cPanel, located in the Advanced section
- Ensure python3 is installed by running the following command
python3 --version
- If not installed, follow these steps to install python3, this will require root access
- Access your server via SSH as the root user or using the Terminal in Root WHM
- Install it using this command
yum -y install python3
- Exit this SSH session or Terminal from Root WHM
- Return to a Terminal in your cPanel, located in the Advanced section.
- If not installed, follow these steps to install python3, this will require root access
- Run the following command
python3 -m pip install --user django
NOTE: While you can use pip3 install --user django to install, sometimes you will get an error if there's more than one pip version available to be used, which is usually the case on our servers. The message that comes up is just about the pip command possibly being a wrapper to another command. To avoid that message, use the python3 command, although getting that message does not mean the install failed or there was a problem with it.
EXAMPLE: Here is the output showing the warning previously mentioned.
userna5@domain.com [~/django.domain.com]# pip3 install django
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.- Alternatively, you can install a specific version with the following command
python3 -m pip install --user django==version
- Alternatively, you can install a specific version with the following command
- Confirm that Django has been installed with the following command
django-admin --version
EXAMPLE: You should see the version number.
userna5@domain.com [~]# django-admin --version
3.2
Django to Python Version Table
Django version | Python version |
2.2 | 3.5, 3.6, 3.7, 3.8 (added in 2.2.8), 3.9 (added in 2.2.17) |
3.0 | 3.6, 3.7, 3.8, 3.9 (added in 3.0.11) |
3.1 | 3.6, 3.7, 3.8, 3.9 (added in 3.1.3) |
3.2 | 3.6, 3.7, 3.8, 3.9, 3.10 (added in 3.2.9) |
4.0 | 3.8, 3.9, 3.10 |
4.1 | 3.8, 3.9, 3.10, 3.11 (added in 4.1.3) |
Comments
0 comments
Article is closed for comments.