Create A Python Django Project The Right Way

Create A Python Django Project The Right Way

As a django developer with over two years of coding experience have seen and gotten allot of messages from beginners asking me what is the right way of creating a django project, after giving numerous answers have decided to write a single blog post where i can reference beginners when ever i get such question, as you read further i will break down the process into different sections.

Creating A virtual Environment

Allot 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

server.jpg

Thank you for reading Check sample project