How to Create Django Project in Microsoft Windows using Command Line

Posted on

Introduction

In this context, this is an article where it only show a specific content just for creating a Django project. Furthermore, the process for creating the Django project in this article will use a local device running Microsoft Windows. So, the content of this article will show step by step for creating a Django project. Actually, before getting on to the actual execution to create the Django project, there are several requirements which is necessary. Those requirements must be available before going on for creating Django project.

How to Create Django Project in Microsoft Windows using Command Line

So, the following are the steps for the preparation or the requirements in order to be able to create a Django project :

  1. First of all, just manage to install python in the local device. As a reference check several articles such as How to Install Python in Microsoft Windows, How to Install Python 3.10 in Microsoft Windows or How to Install Python in Microsoft Windows 11.

  2. Next, just follow after by installing ‘pip’ tool. It is an important tool for installing Django in the next preparation step. For getting a reference on ‘pip’ tool installation, read article How to Install pip in Microsoft Windows and also How to Install pip in Microsoft Windows 11.

  3. Using ‘pip’ tool, create a contained python virtual environment when it is necessary. Just read the article for doing it. There are several articles such as How to Create a Python Virtual Environment with a specific version of Python in Microsoft Windows and also How to Specify Specific Python Version for Creating a Virtual Python Environment in Microsoft Windows. Not to mention the other article How to Create Python Virtual Environment from Anaconda in Microsoft Windows.

  4. Since it is using a local device running Microsoft Windows, just run the Command Line Interface. In this context, it is the Command Prompt with the following appearance :

    Microsoft Windows [Version 10.0.22000.1098]
    (c) Microsoft Corporation. All rights reserved.
    
    C:\Users\Personal>
    
  5. Switch to the folder where the python virtual environment exist as in the third step as follows :

    C:\Users\Personal>cd \
    C:\>cd django
    
    C:\django>dir 
    Volume in drive C is Windows-SSD
    Volume Serial Number is CA30-19A4
    
    Directory of C:\django
    
    06/12/2022 11:39 AM <DIR> .
    06/12/2022 11:39 AM <DIR> ..
    06/12/2022 11:39 AM <DIR> env
    0 File(s) 0 bytes
    3 Dir(s) 9,553,563,648 bytes free
  6. Get into the python virtual environment which in this context it is ‘env’ folder as follows :

    C:\django>cd env
    
    C:\django\env>
    
  7. In order to execute a script for activating the python virtual environment, just get into the ‘Scripts’ folder as follows :

    (env) C:\django\env>dir
    Volume in drive C is Windows-SSD
    Volume Serial Number is CA30-19A4
    
    Directory of C:\django\env
    
    10/11/2022 09:10 AM <DIR> .
    10/17/2022 02:22 PM <DIR> ..
    10/11/2022 09:10 AM <DIR> Lib
    10/11/2022 09:10 AM 84 pyvenv.cfg
    10/11/2022 09:10 AM <DIR> Scripts
    10/11/2022 09:10 AM <DIR> share
    1 File(s) 84 bytes
    5 Dir(s) 193,675,264 bytes free
    
    (env) C:\django\env>
    
    C:\django\env>cd Scripts
    
    C:\django\env\Scripts>
    
  8. And after that, execute the following command to activate the python virtual environment :

    C:\django\env\Scripts>activate
    
    (env) C:\django\env\Scripts>dir
    Volume in drive C is Windows-SSD
    Volume Serial Number is CA30-19A4
    
    Directory of C:\django\env\Scripts
    
    10/11/2022 09:10 AM <DIR> .
    10/11/2022 09:10 AM <DIR> ..
    10/11/2022 09:10 AM 2,091 activate
    10/11/2022 09:10 AM 1,020 activate.bat
    10/11/2022 09:10 AM 22,159 Activate.ps1
    10/11/2022 09:10 AM 107,913 cmark.exe
    10/11/2022 09:10 AM 393 deactivate.bat
    10/11/2022 09:10 AM 107,961 django-admin.exe
    10/11/2022 09:10 AM 1,067 docxcompose-script.py
    10/11/2022 09:10 AM 74,752 docxcompose.exe
    10/11/2022 09:10 AM 107,914 f2py.exe
    10/11/2022 09:10 AM 107,912 flake8.exe
    10/11/2022 09:10 AM 107,913 futurize.exe
    10/11/2022 09:10 AM 107,912 http.exe
    10/11/2022 09:10 AM 107,920 httpie.exe
    10/11/2022 09:10 AM 107,912 https.exe
    10/11/2022 09:10 AM 107,942 normalizer.exe
    10/11/2022 09:10 AM 107,915 pasteurize.exe
    10/11/2022 09:10 AM 107,919 pip.exe
    10/11/2022 09:10 AM 107,919 pip3.10.exe
    10/11/2022 09:10 AM 107,919 pip3.exe
    10/11/2022 09:10 AM 107,917 pisa.exe
    10/11/2022 09:10 AM 107,901 pybidi.exe
    10/11/2022 09:10 AM 107,910 pycodestyle.exe
    10/11/2022 09:10 AM 107,914 pydisasm.exe
    10/11/2022 09:10 AM 107,909 pyflakes.exe
    10/11/2022 09:10 AM 107,913 pygmentize.exe
    10/11/2022 09:10 AM 264,176 python.exe
    10/11/2022 09:10 AM 252,912 pythonw.exe
    10/11/2022 09:10 AM 27,621 pywin32_postinstall.py
    10/11/2022 09:10 AM 3,636 pywin32_testall.py
    10/11/2022 09:10 AM 2,135 spark-parser-coverage
    10/11/2022 09:10 AM 107,914 sqlformat.exe
    10/11/2022 09:10 AM 3,870 svg2pdf
    10/11/2022 09:10 AM 107,905 tqdm.exe
    10/11/2022 09:10 AM 1,972 vba_extract.py
    10/11/2022 09:10 AM 107,917 xhtml2pdf.exe
    10/11/2022 09:10 AM <DIR> __pycache__
    35 File(s) 3,031,975 bytes
    3 Dir(s) 196,792,320 bytes free
    
    (env) C:\django\env\Scripts>
    
  9. The preparation is ready for installing Django and also creating the Django project. So, read How to Install Django in Microsoft Windows as an additional information for installing Django library.

  10. Finally, after successfully installing the Django library, just create the Django project as follows :

    (env) C:\django\env\Scripts>cd \
    (env) C:\django>
    

    Go back to the root of the django folder as in the above execution. Soon after, execute the following step for creating a Django project :

    (env) C:\django>django-admin startproject myproject
    
    (env) C:\django>
    

    In the above context, the creation of the Django project is using the project name of ‘myproject’. Finally, just check the content of the project with the name of ‘myproject’ :

    (env) C:\django>dir
    Volume in drive C is Windows-SSD
    Volume Serial Number is CA30-19A4
    
    Directory of C:\django
    
    10/21/2022 10:51 PM <DIR> .
    10/21/2022 10:40 PM <DIR> ..
    10/21/2022 10:43 PM <DIR> env
    10/21/2022 10:51 PM <DIR> myproject
    0 File(s) 0 bytes
    4 Dir(s) 143,560,704 bytes free
    
    (env) C:\django>cd myproject
    (env) C:\django\myproject>dir
    Volume in drive C is Windows-SSD
    Volume Serial Number is CA30-19A4
    
    Directory of C:\django\myproject
    
    10/21/2022 10:51 PM <DIR> .
    10/21/2022 10:51 PM <DIR> ..
    10/21/2022 10:51 PM 687 manage.py
    10/21/2022 10:51 PM <DIR> myproject
    1 File(s) 687 bytes
    3 Dir(s) 143,495,168 bytes free
    
    (env) C:\django\myproject>cd myproject
    Volume in drive C is Windows-SSD
    Volume Serial Number is CA30-19A4
    
    Directory of C:\django\myproject\myproject
    
    10/21/2022 10:51 PM <DIR> .
    10/21/2022 10:51 PM <DIR> ..
    10/21/2022 10:51 PM 411 asgi.py
    10/21/2022 10:51 PM 3,353 settings.py
    10/21/2022 10:51 PM 772 urls.py
    10/21/2022 10:51 PM 411 wsgi.py
    10/21/2022 10:51 PM 0 __init__.py
    5 File(s) 4,947 bytes
    2 Dir(s) 142,331,904 bytes free
    
    (env) C:\django\myproject\myproject>
    

Leave a Reply