YouTip LogoYouTip

Django Install

Before installing Django, the system needs to have the Python development environment already installed. If you haven't installed Python yet, please first download and install the latest version of Python from the Python official website [https://www.python.org/](https://www.python.org/). Django installation is also simple; you can use the package management tool pip: pip install Django After the installation is complete, you can verify whether Django was installed successfully by running the following command: python3 -m django --version If everything goes smoothly, you will see the installed Django version number, such as: 4.2.7. Recommended development environments: * 1. (#) * 2. (#) * 3. (https://qoder.com/) * 4. ( * * * ## Installing Django on Windows Next, let's take a closer look at Django installation on different systems. If you haven't installed the Python environment yet, you need to download the Python installation package first. 1. Python download address: [https://www.python.org/downloads/](https://www.python.org/downloads/) 2. Django download address: [https://www.djangoproject.com/download/](https://www.djangoproject.com/download/) **Note:** Currently, Django version 1.6.x and above are fully compatible with Python 3.x. ### Python Installation (Skip if already installed) To install Python, you only need to download the python-x.x.x.msi file and then keep clicking the "Next" button. !(#) After installation, you need to set up the Python environment variable. Right-click on Computer->Properties->Advanced->Environment Variables->Modify the system variable path, add the Python installation address. This example uses C:Python33, you need to install according to your actual situation. !(#) ### Django Installation Download the Django compressed package, extract it and place it in the same root directory as the Python installation directory. Enter the Django directory, execute `python setup.py install`, then start the installation. Django will be installed to Python's Libsite-packages. !(#) Then configure the environment variables by adding these directories to the system environment variables: C:Python33Libsite-packagesdjango;C:Python33Scripts. After adding, you can use Django's django-admin.py command to create a new project. !(#) * * * ## Checking if the Installation was Successful Enter the following command to check: >>> import django >>> django.get_version() !(#) If the Django version number is output, the installation is correct. * * * ## Installing Django on Linux ### Yum Installation Method The following installation is performed in a Centos Linux environment. If your Linux system is Ubuntu, please use the apt-get command. By default, the Linux environment already supports Python. You can enter the Python command in the terminal to check if it is installed. Python 3.7.4 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information.>>> ### Installing setuptools Command: # Python3 Installation yum install python3-setuptools # Python2 Installation yum install python2-setuptools After completion, you can use the easy_install command to install django easy_install django Then we enter the following code in the Python interpreter: [root@solar django]# python Python 3.7.4 (default, May 15 2014, 14:49:08)[GCC 4.8.0] on linux2 Type "help", "copyright", "credits" or "license" for more information.>>> import django >>> django.VERSION (3, apply, 6, 'final', 0) We can see the Django version number output, indicating a successful installation. ### Pip Command Installation Method If you haven't installed the pip tool yet, you can refer to: (#). sudo pip3 install Django -i https://pypi.tuna.tsinghua.edu.cn/simple `-i https://pypi.tuna.tsinghua.edu.cn/simple` specifies the Tsinghua mirror source for faster download speed. Specify the download version of Django (3.0.6 can be changed to the version you want): sudo pip3 install Django==3.0.6 -i https://pypi.tuna.tsinghua.edu.cn/simple If pip < 1.4, the installation method is as follows: pip install https://www.djangoproject.com/download/1.11a1/tarball/ ### Source Code Installation Method Download the source code package: [https://www.djangoproject.com/download/](https://www.djangoproject.com/download/) Enter the following commands and install: tar xzvf Django-X.Y.tar.gz # Extract the downloaded package cd Django-X.Y # Enter the Django directory python setup.py install # Execute the installation command After successful installation, Django is located in the site-packages directory of the Python installation directory. * * * ## Installation on Mac ### Download Download the latest stable version from (https://www.djangoproject.com/download "Click here to download DJango"): DJango-3.x.y.tar.gz. Download from the list on the right side of the page, as shown below: !(#) Remember, it's the latest official version. Where **x.y** is the version number. Enter the folder directory where you downloaded the file and execute the following command: (The default on Mac is /Users/xxx/Downloads, xxx is your username) $ tar zxvf Django-3.x.y.tar.gz You can also download the latest version from Github at: [https://github.com/django/django](https://github.com/django/django): git clone https://github.com/django/django.git ### Installation Enter the extracted directory: cd Django-3.x.y sudo python setup.py install After a successful installation, the following information will be output: ……Processing dependencies for Django==3.x.y Finished processing dependencies for Django==3.x.y Then enter our site directory and create a Django project: $ django-admin.py startproject testdj Start the server: cd testdj # Switch to the project we created $ python manage.py runserver ……Starting development server at http://127.0.0.1:8000/Quit the server with CONTROL-C. The above information indicates that the project has started, and the access address is http://127.0.0.1:8000/.
← Django First AppDjango Tutorial β†’