{"id":15880,"date":"2024-09-12T13:47:56","date_gmt":"2024-09-12T17:47:56","guid":{"rendered":"https:\/\/kb.n0c.com\/?post_type=ht_kb&#038;p=15880"},"modified":"2026-09-28T10:16:20","modified_gmt":"2026-09-28T14:16:20","slug":"how-to-install-django","status":"publish","type":"ht_kb","link":"https:\/\/kb.n0c.com\/en\/knowledge-base\/how-to-install-django\/","title":{"rendered":"How to Install Django"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>This article shows how to install a Django application on an account.<\/p>\n\n\n\n<p>Django is a free, open-source Python web framework that helps developers build secure and scalable websites quickly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Procedure<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"InstallerDjangosurWorld-Pr\u00e9parationdel'application\">Step 1 &#8212; Preparation of the Python Application<\/h3>\n\n\n\n<p>If you have not already done so, <a href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/python-application-management\/#:~:text=in%20the%20interface%3A-,Implementation%20of%20a%20New%20Python%20Application%20with%20N0C,-To%20explain%20the\">add a Python application via the N0C panel<\/a>. We recommend using the latest Django-compatible version of Python.<\/p>\n\n\n\n<p>For the sake of clarity through the article, we will say that our application is called <strong>myapp<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"InstallerDjangosurWorld-ConnexionSSH\">Step 2 &#8212; Connect in SSH<\/h3>\n\n\n\n<p>As the rest of the operations will be carried out in SSH, please see <a href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/how-to-create-an-ssh-key-and-connect-to-an-account\/\">how to create an SSH key and connect to an account remotely<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"InstallerDjangosurWorld-Activerl'environnementPython\">Step 3 &#8212; Activate the Python Environment<\/h3>\n\n\n\n<p>To access the Python environment of the application you&#8217;ve just created, you need to <a href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/python-application-management\/#:~:text=be%20%E2%80%9CHello%20World!%E2%80%9D.-,Step%20%233%20%E2%80%93%20Call%20the%20Environment%20of%20the%20Application,-Before%20performing%20any\">call the environment of the application<\/a>.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source \/home\/abcdef\/virtualenv\/myapp\/3.11\/bin\/activate<\/code><\/pre>\n\n\n\n<p>Once the environment is active, navigate to your application folder using the <a href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/n0c-filemanager\/\">file manager<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"InstallerDjangosurWorld-Django\">Step 4 &#8212; Django Installation<\/h3>\n\n\n\n<p>To use Django, you have to install the Python dependencies needed to run the application. The following command does just that:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pip install Django<\/pre>\n\n\n\n<p>When installation is complete, a confirmation message is displayed.<\/p>\n\n\n\n<p>By default, Django is configured with SQLite. However, this SQL engine is not recommended for a production environment. With the following command, you will install the mysqlclient library to connect to MySQL (you can also use PostgreSQL if you prefer):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pip install mysqlclient<\/pre>\n\n\n\n<p>When installation is complete, a confirmation message is displayed.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"InstallerDjangosurWorld-Nouvelleinstallation\">New Installation<\/h4>\n\n\n\n<p>If you want to install a new Django application, you can use the django-admin CLI to initialize your application.<\/p>\n\n\n\n<p>Initialization in the folder you have chosen for your Python application is done by running the command below. You can change \u201cmyapp\u201d to the desired application name:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd myapp\ndjango-admin startproject myapp .<\/pre>\n\n\n\n<p>Please note that the dot at the end of the order is important.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"InstallerDjangosurWorld-Installationexistante\">Existing Installation<\/h4>\n\n\n\n<p>If you already have a Django application and wish to install it on your account, you will need to upload the files to a subfolder of the folder chosen for the Python application. In this tutorial, we will use \u201cmyapp\u201d as the subfolder and application name, but you can change it to suit your preference.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"InstallerDjangosurWorld-ConfigurationdeDjango\">Step 5 &#8212; Django Configuration<\/h3>\n\n\n\n<p>Now that your application files have been installed, it is time to configure them.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"InstallerDjangosurWorld-Basededonn\u00e9es\">Database Creation<\/h4>\n\n\n\n<p>If you have not already done so, please follow this guide to <a href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/databases\/#:~:text=at%20the%20bottom.-,Create%20an%20SQL%20Database%20with%20a%20New%20User,-Click%20on%20the\">create a SQL database with a user<\/a>.<\/p>\n\n\n\n<p>Once the database has been created, in the <a href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/n0c-filemanager\/\">file manager<\/a>, modify the Django configuration file using the information provided in the <a href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/databases\/#sql-databases-management:~:text=for%20managing%20passwords-,SQL%20Databases%20Management,-Access%20to%20the\">interface for managing your database<\/a>. In our case, this is the file myapp\/myapp\/settings.py :<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">DATABASES = {\n'default': {\n       \t'ENGINE': 'django.db.backends.mysql',\n        'NAME': 'name of the database',\n        'USER': 'name of the user with priviledges',\n       \t'PASSWORD': 'your password',\n        'HOST': '127.0.0.1',\n       \t'PORT': '3306',\n    }\n}<\/pre>\n\n\n\n<p>For more information on configuring your Django application, we recommend that you consult the official Django documentation:&nbsp;<a href=\"https:\/\/docs.djangoproject.com\/fr\/2.2\/ref\/settings\/#databases\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/docs.djangoproject.com\/fr\/2.2\/ref\/settings\/#databases<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Defining Authorized Hosts<\/h4>\n\n\n\n<p>Once again, you need to modify Django&#8217;s configuration file to specify the domain name that this Django site can serve. This is a security measure to prevent attacks on the HTTP Host header, which are possible even in many apparently secure web server configurations.<\/p>\n\n\n\n<p>In the <a href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/n0c-filemanager\/\">file manager<\/a>, edit the file myapp\/myapp\/settings.py to enclose your domain name in square brackets:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ALLOWED_HOSTS = &#91;\"domain name\"]<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"InstallerDjangosurWorld-Serveur(Passenger)\">Server (Passenger)<\/h4>\n\n\n\n<p>We assume that servers use Passenger to run Python. Passenger is responsible for automatically starting your application when someone visits your site. For this reason, you should not launch your application manually.<\/p>\n\n\n\n<p>To connect your application with Passenger, you will need to modify the \u201cpassenger_wsgi.py\u201d file in the folder you have chosen for your Python application.<\/p>\n\n\n\n<p>To do this, use the <a href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/n0c-filemanager\/\">file manager<\/a> to replace the entire contents of the file with the code below. Note that you must modify \u201cmyapp\u201d if you have chosen a different name for your application:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import myapp.wsgi\napplication = myapp.wsgi.application<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"InstallerDjangosurWorld-Conclusion\">Step 6 &#8212; Test<\/h3>\n\n\n\n<p>Check that your Django application is working correctly by using its URL, as it appears in the <a href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/python-application-management\/#:~:text=com\/en\/.-,Access%20to%20Python%20in%20N0C,-In%20the%20Sidebar\">application management interface<\/a> of the MG Panel.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"InstallerDjangosurWorld-Astuces\">Tips<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you make any changes to your application&#8217;s code, be sure to <a href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/python-application-management\/#:~:text=Click%20on%20the%20Restart%20icon%20next%20to%20the%20application%20to%20activate%20(in%20our%20example%2C%20codepython)%3A%20%C2%A0\">restart the Python application via the MG Panel<\/a> for the changes to take effect.<\/li>\n\n\n\n<li>If you get errors when you visit the site where your application is installed, we recommend you follow the guide on <a href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/debugging-a-nodejs-ruby-or-python-application-with-n0c\/\">how to debug a Node.js, Ruby or Python application<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Introduction This article shows how to install a Django application on an account. Django is a free, open-source Python web framework that helps developers build secure and scalable websites quickly. Procedure Step 1 &#8212; Preparation of the Python Application If you have not already done so, add a Python application&#8230;<\/p>\n","protected":false},"author":4,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[163],"ht-kb-tag":[],"class_list":["post-15880","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-languages"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Install Django - N0C KB<\/title>\n<meta name=\"description\" content=\"This article shows how to install a Django application on an account.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/how-to-install-django\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install Django - N0C KB\" \/>\n<meta property=\"og:description\" content=\"This article shows how to install a Django application on an account.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kb.n0c.com\/en\/knowledge-base\/how-to-install-django\/\" \/>\n<meta property=\"og:site_name\" content=\"N0C KB\" \/>\n<meta property=\"article:modified_time\" content=\"2026-09-28T14:16:20+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/kb.n0c.com\\\/en\\\/knowledge-base\\\/how-to-install-django\\\/\",\"url\":\"https:\\\/\\\/kb.n0c.com\\\/en\\\/knowledge-base\\\/how-to-install-django\\\/\",\"name\":\"How to Install Django - N0C KB\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kb.n0c.com\\\/#website\"},\"datePublished\":\"2024-09-12T17:47:56+00:00\",\"dateModified\":\"2026-09-28T14:16:20+00:00\",\"description\":\"This article shows how to install a Django application on an account.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/kb.n0c.com\\\/en\\\/knowledge-base\\\/how-to-install-django\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/kb.n0c.com\\\/en\\\/knowledge-base\\\/how-to-install-django\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/kb.n0c.com\\\/en\\\/knowledge-base\\\/how-to-install-django\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/kb.n0c.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Articles\",\"item\":\"https:\\\/\\\/kb.n0c.com\\\/en\\\/knowledge-base\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Install Django\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/kb.n0c.com\\\/#website\",\"url\":\"https:\\\/\\\/kb.n0c.com\\\/\",\"name\":\"N0C KB\",\"description\":\"Official documentation of the N0C hosting platform\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/kb.n0c.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Install Django - N0C KB","description":"This article shows how to install a Django application on an account.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kb.n0c.com\/en\/knowledge-base\/how-to-install-django\/","og_locale":"en_US","og_type":"article","og_title":"How to Install Django - N0C KB","og_description":"This article shows how to install a Django application on an account.","og_url":"https:\/\/kb.n0c.com\/en\/knowledge-base\/how-to-install-django\/","og_site_name":"N0C KB","article_modified_time":"2026-09-28T14:16:20+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/kb.n0c.com\/en\/knowledge-base\/how-to-install-django\/","url":"https:\/\/kb.n0c.com\/en\/knowledge-base\/how-to-install-django\/","name":"How to Install Django - N0C KB","isPartOf":{"@id":"https:\/\/kb.n0c.com\/#website"},"datePublished":"2024-09-12T17:47:56+00:00","dateModified":"2026-09-28T14:16:20+00:00","description":"This article shows how to install a Django application on an account.","breadcrumb":{"@id":"https:\/\/kb.n0c.com\/en\/knowledge-base\/how-to-install-django\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kb.n0c.com\/en\/knowledge-base\/how-to-install-django\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kb.n0c.com\/en\/knowledge-base\/how-to-install-django\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/kb.n0c.com\/"},{"@type":"ListItem","position":2,"name":"Articles","item":"https:\/\/kb.n0c.com\/en\/knowledge-base\/"},{"@type":"ListItem","position":3,"name":"How to Install Django"}]},{"@type":"WebSite","@id":"https:\/\/kb.n0c.com\/#website","url":"https:\/\/kb.n0c.com\/","name":"N0C KB","description":"Official documentation of the N0C hosting platform","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kb.n0c.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/kb.n0c.com\/en\/wp-json\/wp\/v2\/ht-kb\/15880","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.n0c.com\/en\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/kb.n0c.com\/en\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/kb.n0c.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.n0c.com\/en\/wp-json\/wp\/v2\/comments?post=15880"}],"version-history":[{"count":7,"href":"https:\/\/kb.n0c.com\/en\/wp-json\/wp\/v2\/ht-kb\/15880\/revisions"}],"predecessor-version":[{"id":25242,"href":"https:\/\/kb.n0c.com\/en\/wp-json\/wp\/v2\/ht-kb\/15880\/revisions\/25242"}],"wp:attachment":[{"href":"https:\/\/kb.n0c.com\/en\/wp-json\/wp\/v2\/media?parent=15880"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/kb.n0c.com\/en\/wp-json\/wp\/v2\/ht-kb-category?post=15880"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/kb.n0c.com\/en\/wp-json\/wp\/v2\/ht-kb-tag?post=15880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}