<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Control WebPanel Wiki &#187; Install Django</title>
	<atom:link href="https://wiki.centos-webpanel.com/tag/install-django/feed" rel="self" type="application/rss+xml" />
	<link>https://wiki.centos-webpanel.com</link>
	<description>CentOS WebPanel Wiki</description>
	<lastBuildDate>Wed, 12 Feb 2025 20:38:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.1</generator>
	<item>
		<title>Install Django</title>
		<link>https://wiki.centos-webpanel.com/install-django</link>
		<comments>https://wiki.centos-webpanel.com/install-django#comments</comments>
		<pubDate>Wed, 06 May 2020 11:14:34 +0000</pubDate>
		<dc:creator><![CDATA[publisher]]></dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Install Django]]></category>

		<guid isPermaLink="false">http://wiki.centos-webpanel.com/?p=1369</guid>
		<description><![CDATA[Django is a free and open-source high-level Python Web framework. Being a Python Web framework, Django requires Python What Python version should I use with Django? Python 3 is recommended. Django 1.11 is the last version to support Python 2.7. Support for Python 2.7 and Django 1.11 ends in 2020. Since newer versions of Python [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Django is a free and open-source high-level Python Web framework.<br />
Being a Python Web framework, Django requires Python</p>
<p><strong>What Python version should I use with Django?</strong></p>
<p>Python 3 is recommended. Django 1.11 is the last version to support Python 2.7. Support for Python 2.7 and Django 1.11 ends in 2020. Since newer versions of Python are often faster, have more features, and are better supported, the latest version of Python 3 is recommended.</p>
<p>You don’t lose anything in Django by using an older release, but you don’t take advantage of the improvements and optimizations in newer Python releases.</p>
<table style="width:100%">
<tr>
<th>Django versions</th>
<th>Python versions</th>
</tr>
<tr>
<td>1.11</td>
<td>2.7, 3.4, 3.5, 3.6, 3.7</td>
</tr>
<tr>
<td>2.0</td>
<td>3.4, 3.5, 3.6, 3.7</td>
<tr>
<td>2.1, 2.2</td>
<td>3.5, 3.6, 3.7</td>
</tr>
</tr>
</table>
<p>&nbsp;<br />
<strong>Installation steps</strong></p>
<p><strong>1. Install the latest version of python</strong></p>
<p><strong>a) Prepare Your System</strong></p>
<pre>
# yum -y groupinstall development
# yum -y install zlib-devel libffi-devel
</pre>
<p><strong>b) Download python Source Code</strong></p>
<pre>
# cd /usr/local/src
# wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
</pre>
<p><strong>c) Build Python</strong></p>
<pre>
# cd /usr/local/src
# tar xvf Python-3.7.3.tgz
# cd Python-3.7.3
# ./configure --with-ensurepip=install --enable-shared
# make
# make install
</pre>
<p>After installation please create a symlink for the shared object library by using the following command:</p>
<pre>ln -s /usr/local/lib/libpython3.7m.so.1.0 /usr/lib64/libpython3.7m.so.1.0</pre>
<p>Upgrade pip</p>
<pre>pip3.7 install --upgrade pip</pre>
<p><strong>Note:</strong> Please note that after installation, the new python binary path will be located at /usr/local/bin/python</p>
<p><strong>2. Installing Django</strong><br />
The recommended way to install Django is to use pip<br />
&nbsp;<br />
<strong> Install django with the following command:</strong></p>
<pre># pip3.7 install django</pre>
<p>This will install the latest version of django.To install a particular version of django,for example version 2.0</p>
<pre># pip3.7 install django==2.0</pre>
<p>To tell Django is installed and which version, run the following command in a shell prompt</p>
<pre># python3.7 -m django --version</pre>
<p>You can also confirm it’s installed correctly type:</p>
<p><strong>3. Installing Django in Python Virtual Enviroment</strong><br />
&nbsp;<br />
The steps above are for installing Django globally. However, Django can be installed into a virtualenv. Virtualenv is a tool used to create an isolated Python environment. This environment has its own installation directories that don't share libraries with other virtualenv environments (and optionally doesn't access the globally installed libraries either)<br />
&nbsp;<br />
<strong>Installing Virtualenv using pip3</strong></p>
<pre>#pip3.7 install virtualenv </pre>
<p><strong>3.1. You'll need the full path to the Python 3 version of virtualenv, so run the following to view it:</strong></p>
<pre>#which virtualenv</pre>
<p><strong>3.2. Navigate to your site's directory, where you'll create the new virtual environment:</strong></p>
<pre>#cd /home/username</pre>
<p><strong>3.3. Create the virtual environment while you specify the version of Python you wish to use. </strong></p>
<p>The following command creates a virtualenv named 'project1' and uses the -p flag to specify the full path to the Python3 version you just installed</p>
<pre>#virtualenv -p /usr/local/bin/python3.7 project1</pre>
<p>This command creates a local copy of your environment specific to this website. While working on this website, you should activate the local environment in order to make sure you're working with the right versions of your tools and packages.</p>
<p><strong>3.4. To activate the new virtual environment, run the following:</strong></p>
<pre># source project1/bin/activate</pre>
<p>The name of the current virtual environment appears to the left of the prompt. For example:</p>
<pre>(project1) [root@server]#</pre>
<p>Within the environment, install the Django package using pip. Installing Django allows us to create and run Django applications</p>
<pre>(project1) [root@server]# pip3.7 install django</pre>
<p>You can also install all other packages in the virtual environment that you may need in your development.</p>
<p>For Example, you can install mysqlclient by using the following command:</p>
<pre>(project1) [root@server]# pip3.7 install mysqlclient</pre>
<p>Going forward, whenever you create new Django projects you simply need to create a new virtual environment, install a fresh version of Django and other packages that may be needed.</p>
<p><strong>3.5. Deactivating your virtualenv</strong></p>
<p>When finished working in the virtual environment, you can deactivate it by running the following:</p>
<pre>(project1) [root@server]# deactivate</pre>
<p>This puts you back into your Shell user's default settings.<br />
If you want to go back into your virtualenv, please refer to <strong>3.4</strong> above.</p>
]]></content:encoded>
			<wfw:commentRss>https://wiki.centos-webpanel.com/install-django/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
