> In your system must have python installed
> Install any IDE like (VS code, Pycharm, etc.)
Step 1: Create a separate folder in your system where you want to place your project.
Step 2: Now Before Installing any dependencies just create virtual environment using this command:
virtualenv name_of_virtualenv(venv)
Step 3: Activate virtual environment which you created just before using this command:
source venv/bin/activate
Step 4: Now Install Django using this command:
pip3 install django
Step 5: Next step is creating a project using this command:
django-admin startproject project_name.
Step 6: Now You can create number of applications in that project as per your requirements using this command:
python3 manage.py startapp app_name
Step 7: Now you have added all application name inside settings.py file in
1 2 3 4 5 6 7 8 9 10 |
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'app1', ] |
Step 8: Now you have to run make migrations command to generate sql for models:
python3 manage.py makemigrations
Step 9: For Finally reflect changes related to model on databases you have to run:
python3 manage.py migrate
Step 10: Now you can run your project using this command:
python3 manage.py runserver
Step 11: You can also change default port using this command:
python3 manage.py runserver 9000
Step 12: You can also take all dependencies with version details using this command:
pip3 freeze > requirements.txt
Stay tuned with us for more interesting articles and fun fact related to Python and Django Veni vidi vici …..
bluethinkinc_blog
2022-07-14