{"id":120242,"date":"2024-12-17T15:18:54","date_gmt":"2024-12-17T15:18:54","guid":{"rendered":"\/tutorials\/?p=120242"},"modified":"2025-08-26T10:11:41","modified_gmt":"2025-08-26T10:11:41","slug":"how-to-install-django","status":"publish","type":"post","link":"\/tutorials\/how-to-install-django","title":{"rendered":"How to install Django? Using Hostinger VPS template and manually\u00a0"},"content":{"rendered":"<p>Django is a high-level Python web framework that promotes rapid development and clean, pragmatic design. It simplifies many web development tasks, so you can focus on building your application without reinventing the wheel.<\/p><p>In this tutorial, we&rsquo;ll guide you through two methods to install Django on your virtual private server (VPS): using the Hostinger template for a quick setup and manually for more control over your environment.<\/p><p>By the end, you&rsquo;ll have Django running in a virtual environment, ready for development.<\/p><p>\n\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-prerequisites\">Prerequisites<\/h2><p>Before installing Django, it&rsquo;s important to be familiar with a few key concepts:<\/p><ul class=\"wp-block-list\">\n<li><strong>Basic Python knowledge<\/strong> &ndash; Django is a Python-based web framework, so you should understand Python fundamentals like data types, control flow (if\/else, loops), functions, classes, and modules. Familiarity with Python libraries and tools will also be beneficial.<\/li>\n\n\n\n<li><strong>HTML, CSS, and JavaScript basics<\/strong> &ndash; while Django focuses on back-end development, basic knowledge of front-end technologies such as HTML, CSS, and JavaScript is essential for <a href=\"\/tutorials\/working-with-django-templates\">creating templates<\/a> and managing static files.<\/li>\n\n\n\n<li><strong>Understanding of databases<\/strong> &ndash; Django interacts closely with databases to store and manage data. Basic database concepts (tables, records, primary and foreign keys) are important. Knowledge of SQL is helpful, though Django&rsquo;s object-relational mapping (ORM) abstracts many database operations.<\/li>\n\n\n\n<li><strong>Command-line interface (CLI) familiarity<\/strong> &ndash; many Django tasks are performed through the command line. Basic knowledge of <a href=\"\/tutorials\/linux-commands\">Linux commands<\/a> is necessary for managing your project.<\/li>\n<\/ul><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Suggested Reading<\/h4>\n                    <p>Check out <a href=\"\/tutorials\/what-can-you-do-with-python\">Python real-life use cases<\/a> and learning tips in our article.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-install-django-using-hostinger-s-vps-template\">How to install Django using Hostinger&rsquo;s VPS template?<\/h2><p>Hostinger makes it easy to set up Django on your VPS using a dedicated template. This method simplifies the installation process, letting you avoid command-line setup while providing a stable and optimized environment for your Django application.<\/p><p>To start, consider your project&rsquo;s needs:<\/p><ul class=\"wp-block-list\">\n<li><strong>CPU and RAM<\/strong> &ndash; a faster CPU and more RAM improve performance, particularly for complex applications or high traffic.<\/li>\n\n\n\n<li><strong>Storage<\/strong> &ndash; Django applications handle databases and static files. Ensure your VPS has sufficient SSD storage for these requirements.<\/li>\n\n\n\n<li><strong>Bandwidth<\/strong> &ndash; choose a plan with enough bandwidth to handle expected traffic without slowdowns.<\/li>\n<\/ul><p>For a basic Django project, our <a href=\"\/vps\/django-hosting\">Django VPS lower-tier plans<\/a>, like <strong>KVM 1<\/strong> or <strong>KVM 2<\/strong>, will suffice. As your project grows, you can easily scale up to a higher-tier plan.<\/p><p>After selecting your desired plan, set up the framework by choosing the <strong>OpenLiteSpeed and Django (built on Ubuntu 24.04)<\/strong> template during the onboarding process.<\/p><p>If you use our regular VPS plan or have previously installed a different template, follow these steps instead:<\/p><p>\n\n\n    <p class=\"warning\">\n            <\/p>\n    \n\n\n\n<\/p><ol class=\"wp-block-list\">\n<li>Log in to hPanel and navigate to <strong>VPS &rarr; Manage<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e92d1a1f2a6\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"2846\" height=\"776\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-manage-highlighted.png\/public\" alt=\"The Manage button in hPanel\" class=\"wp-image-120243\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-manage-highlighted.png\/w=2846,fit=scale-down 2846w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-manage-highlighted.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-manage-highlighted.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-manage-highlighted.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-manage-highlighted.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-manage-highlighted.png\/w=1536,fit=scale-down 1536w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-manage-highlighted.png\/w=2048,fit=scale-down 2048w\" sizes=\"(max-width: 2846px) 100vw, 2846px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"2\" class=\"wp-block-list\">\n<li>On your VPS dashboard&rsquo;s left sidebar, select <strong>OS &amp; Panel &rarr; Operating System<\/strong>.<\/li>\n\n\n\n<li>In the <strong>Change OS<\/strong> section, go to the <strong>Application<\/strong> tab.<\/li>\n\n\n\n<li>Select <strong>OpenLiteSpeed with Django<\/strong>. You can also find it easily using the search menu.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e92d1a210b1\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"2244\" height=\"608\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-operating-system-openlitespeed-with-django-highlighted.png\/public\" alt=\"The OpenLiteSpeed with Django template in hPanel's VPS\" class=\"wp-image-120244\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-operating-system-openlitespeed-with-django-highlighted.png\/w=2244,fit=scale-down 2244w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-operating-system-openlitespeed-with-django-highlighted.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-operating-system-openlitespeed-with-django-highlighted.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-operating-system-openlitespeed-with-django-highlighted.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-operating-system-openlitespeed-with-django-highlighted.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-operating-system-openlitespeed-with-django-highlighted.png\/w=1536,fit=scale-down 1536w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-operating-system-openlitespeed-with-django-highlighted.png\/w=2048,fit=scale-down 2048w\" sizes=\"(max-width: 2244px) 100vw, 2244px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"5\" class=\"wp-block-list\">\n<li>When the popup appears, click <strong>Change OS<\/strong>, acknowledge the data deletion warning, and enter a new password for your server.<\/li>\n\n\n\n<li>Hit <strong>Confirm<\/strong> and wait for the process to complete within <strong>10<\/strong> minutes.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e92d1a2329b\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1272\" height=\"908\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-change-operating-system-confirm-highlighted.png\/public\" alt=\"The Confirm button in the Change operating system popup of hPanel's VPS\" class=\"wp-image-120245\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-change-operating-system-confirm-highlighted.png\/w=1272,fit=scale-down 1272w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-change-operating-system-confirm-highlighted.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-change-operating-system-confirm-highlighted.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-change-operating-system-confirm-highlighted.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/hpanel-vps-change-operating-system-confirm-highlighted.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1272px) 100vw, 1272px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Once done, you&rsquo;ll have a fully-configured server running Ubuntu <strong>24.04<\/strong> with Django and the OpenLiteSpeed web server.<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">&#128161; Pro tip<\/h4>\n                    <p>You can change your server's password later if needed, either via the <strong>Settings<\/strong> menu or by using <strong>Kodee<\/strong>, our AI assistant. Using <strong>Kodee<\/strong> is simpler &ndash; just type a prompt asking it to change your password and include the new one. For example: \"Please change my server password to MyNewSecurePassword123.\"<\/p>\n                <\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/public\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-install-django-manually\">How to install Django manually?<\/h2><p>If you prefer using a different operating system, web server, or need more flexibility in setting up Django, you can manually install it using commands. Follow these steps:<\/p><h3 class=\"wp-block-heading\" id=\"h-1-access-your-vps\">1. Access your VPS<\/h3><p>To manually install Django, you first need to connect to your VPS using a terminal or an <a href=\"\/tutorials\/how-to-use-putty-ssh\">SSH client like PuTTY<\/a>. Here are the instructions:<\/p><ol class=\"wp-block-list\">\n<li>Open your terminal and run the following command, replacing <strong>your_vps_ip<\/strong> with your VPS&rsquo; actual IP address:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh root@your_vps_ip<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>When prompted, enter your root password to gain server access.<\/li>\n<\/ol><p>For <a href=\"\/vps-hosting\">Hostinger VPS<\/a> customers, you can find your server&rsquo;s IP and root login credentials by navigating to the <strong>VPS details<\/strong> section in your VPS dashboard.<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e92d1a249de\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2025\/02\/hpanel-vps-overview-ssh-username-ipv4-highlighted-1024x329.png\" alt=\"The SSH username and IPv4 information in the VPS Overview page of hPanel\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>If you don&rsquo;t want to use external software, Hostinger users can also access their server via the <strong>Browser terminal<\/strong> feature. Simply hit the button in the top right corner of your VPS dashboard to log in automatically.<\/p><ol start=\"3\" class=\"wp-block-list\">\n<li>Once logged in, it&rsquo;s a good practice to update and upgrade your server with:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apt update &amp;&amp; apt upgrade -y<\/pre><p>After updating, your VPS will be ready to install Python and other required dependencies for Django development.<\/p><h3 class=\"wp-block-heading\" id=\"h-2-install-python-and-pip\">2. Install Python and pip<\/h3><p>To run Django, you&rsquo;ll need to <a href=\"\/tutorials\/install-pip-in-ubuntu\">install Python and pip on your VPS<\/a>. Most modern Linux distributions, like Ubuntu, come with Python pre-installed.<\/p><p>Here&rsquo;s how to verify if Python is installed and to install or update it if necessary:<\/p><ol class=\"wp-block-list\">\n<li>Run the following command to check the current version of Python:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">python3 --version<\/pre><ul class=\"wp-block-list\">\n<li>If the command returns the Python version number, Python is already installed, and you just need to install <strong>pip<\/strong>, the package installer for Python.<\/li>\n<\/ul><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e92d1a269b7\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1806\" height=\"220\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-python3-version-output.png\/public\" alt=\"The python3 --version command's output in the terminal\" class=\"wp-image-120247\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-python3-version-output.png\/w=1806,fit=scale-down 1806w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-python3-version-output.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-python3-version-output.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-python3-version-output.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-python3-version-output.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-python3-version-output.png\/w=1536,fit=scale-down 1536w\" sizes=\"(max-width: 1806px) 100vw, 1806px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ul class=\"wp-block-list\">\n<li>If it returns an error, you&rsquo;ll need to install Python.<\/li>\n<\/ul><ol start=\"2\" class=\"wp-block-list\">\n<li>Here are the commands to install Python <strong>3<\/strong> and <strong>pip<\/strong>:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update\nsudo apt install python3 python3-pip -y<\/pre><p>After that, you&rsquo;re ready to set up a virtual environment for your Django project.<\/p><h3 class=\"wp-block-heading\" id=\"h-3-set-up-a-virtual-environment\">3. Set up a virtual environment<\/h3><p>A virtual environment is an isolated space where you can install Python packages and dependencies for a specific project. This method doesn&rsquo;t affect the system-wide Python environment or other projects.<\/p><p>Using a virtual environment is especially important when working with Django, as different projects may require different versions of packages. It ensures that each project&rsquo;s dependencies are neatly contained and don&rsquo;t conflict with others.<\/p><p>Follow these steps to <a href=\"\/tutorials\/how-to-create-a-python-virtual-environment\">set up a virtual environment on your VPS<\/a>:<\/p><ol class=\"wp-block-list\">\n<li>Install the <strong>venv<\/strong> package, if it&rsquo;s not already installed:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt install python3-venv -y<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Create and navigate to your project directory. Here, we name it <strong>myproject<\/strong>:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir myproject\ncd myproject<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Create a virtual environment, replacing <strong>env_name<\/strong> with your preferred name:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">python3 -m venv env_name<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Activate the virtual environment:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">source env_name\/bin\/activate<\/pre><p>Once activated, your shell prompt will change to reflect the virtual environment name, indicating you&rsquo;re working within it.<\/p><h3 class=\"wp-block-heading\" id=\"h-4-install-django\">4. Install Django<\/h3><p>The last step is to install Django itself. You can do it by following these steps:<\/p><ol class=\"wp-block-list\">\n<li>Use <strong>pip<\/strong> to install the latest Django version:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pip install django<\/pre><p>This will download and install Django and all its dependencies within the virtual environment.<\/p><ol start=\"2\" class=\"wp-block-list\">\n<li>Execute this command to check if Django is installed and to see the version:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">django-admin --version<\/pre><p>You should see an output showing the current Django version, indicating that installation was successful.<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e92d1a2948b\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"2674\" height=\"184\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-environment-django-admin-version-output.png\/public\" alt=\"The django-admin --version command's output in the virtual environment shell of terminal\" class=\"wp-image-120248\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-environment-django-admin-version-output.png\/w=2674,fit=scale-down 2674w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-environment-django-admin-version-output.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-environment-django-admin-version-output.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-environment-django-admin-version-output.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-environment-django-admin-version-output.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-environment-django-admin-version-output.png\/w=1536,fit=scale-down 1536w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/12\/terminal-environment-django-admin-version-output.png\/w=2048,fit=scale-down 2048w\" sizes=\"(max-width: 2674px) 100vw, 2674px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>That&rsquo;s it! Now you can start <a href=\"\/tutorials\/how-to-create-a-django-project\">building your Django application<\/a>.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>In this guide, we&rsquo;ve covered installing Django on your VPS using Hostinger&rsquo;s pre-configured template and through manual installation.<\/p><p>The former simplifies the process with just a few clicks, perfect for users who prefer easy setup. In contrast, the latter offers greater flexibility, especially if you use a different OS or need more control over your configuration.<\/p><p>With either approach, you now have a clean, isolated environment to efficiently build your Django application.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-install-django-faq\">How to install Django FAQ<\/h2><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1734447730686\"><h3 class=\"schema-faq-question\">Is Python required to install Django?<\/h3> <p class=\"schema-faq-answer\">Yes, Python is required to install Django. To install the latest version of Python and <strong>pip<\/strong>, run the following command: <strong>sudo apt install python3 python3-pip -y<\/strong><\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1734447775251\"><h3 class=\"schema-faq-question\">What version of Python do I need to install Django?<\/h3> <p class=\"schema-faq-answer\">Django supports older Python versions, but we suggest installing a newer version for better features, support, and performance. Python <strong>3.8<\/strong> or higher is ideal for compatibility with the latest Django features.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1734447793647\"><h3 class=\"schema-faq-question\">How do I verify my Django installation?<\/h3> <p class=\"schema-faq-answer\">Run the <strong>django-admin &ndash;version<\/strong> command in your terminal. If Django is successfully installed, you will see the version number. If you see an error message, Django is not installed.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Django is a high-level Python web framework that promotes rapid development and clean, pragmatic design. It simplifies many web development [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/tutorials\/how-to-install-django\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":185,"featured_media":120144,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to install the Django?","rank_math_description":"Check this article to learn how to install Django on a VPS: 1. Automatically with Hostinger's VPS template 2. Manually using Linux commands.","rank_math_focus_keyword":"how to install django","footnotes":""},"categories":[22646,22644],"tags":[],"class_list":["post-120242","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pre-installed-applications","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-install-django","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-install-django","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-install-django","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-install-django","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-install-django","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-install-django","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-install-django","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-install-django","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/120242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/users\/185"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/comments?post=120242"}],"version-history":[{"count":9,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/120242\/revisions"}],"predecessor-version":[{"id":130215,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/120242\/revisions\/130215"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media\/120144"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media?parent=120242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/categories?post=120242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/tags?post=120242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}