Step 1: Create a folder and install Virtual Environment
Create a folder in your computer( Ex: My Django App) and open that folder in Code Editor like VS code (Right click and choose "Open with VS Code").
py -m venv venv
Note: Here "venv" is a virtual environment name.
Step 2: Activate the Virtual Environment and install Django in a virtual environment
Activate the virtual environment using the following command
venv\Scripts\Activate.ps1
Note: If you cannot activate virtual environment and getting error message like "venv/Scripts/Activate.ps1 : File E:\Django for Production office apps\venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170."
Solution: You need to set powershell ExecutionPolicy to Unrestricted using the following command.Just paste the command in Power shell.
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
Then install the Django using the following command
pip install django
Step 3: Create a main project and create a separate app
Create a main Django project using the following command
django-admin startproject main .
Note: Here "main" is the main project name. You can use the command without the dot "django-admin startproject main". Using the command without dot will create a folder with your main project name and add files with the same name inside the folder.
Step 4: Connect the app with the main project and connect the separate app URLs to the main project
Step 5: Run the app.
Run the app using the following command
py manage.py runserver
Step 6 (optional): Create another separate app to add a Custom user model (if it's necessary)
© 2024 Webapptiv. All rights reserved.