As a Django developer with over two years of experience, I have received numerous messages from beginners asking about the right way to create a Django project. After providing various answers, I decided to write a single blog post to serve as a reference for beginners. In this post, I will break down the process into different sections.
Creating A virtual Environment
A lot of beginners don't really know what a virtual environment is so i will just give you a shorter description of a virtual environment.
A virtual environment is a Python environment where packages can be installed specifically for a project and those packages can only be accessed within the project and not other projects(container)
Steps For Creating Your First Virtual Environment
Create Your Project Folder
c: mkdir project
c: cd project
Create And Activate Virtual Environment
c:\project: python -m venv env
c:\project: env/scripts/activate #powershell
c:\project: env\scripts\activate #cmd
(env) c:\project:
Creating Your Django Project
Install Django in your activated environment
(env) c:\project: pip install django
Create your Django project
(env) c:\project: django-admin startproject Todo . #take note of that preriod
After the successful running of this command you would notice some files in your folder those are the project files
Create and register your app
(env) c:\project: py manage.py startapp app #app is the name
After creating your app make sure you register it in the settings.py
Start your Django server
(env) c:\project: py manage.py runserver
after starting you server the below image is what you get in your browser
Thank you for reading Check sample project