Skip to content

Instantly share code, notes, and snippets.

@sanjivyash
Last active September 5, 2020 10:41
Show Gist options
  • Save sanjivyash/ed51e15dcfa82cf784e13d24a2e97f61 to your computer and use it in GitHub Desktop.
Save sanjivyash/ed51e15dcfa82cf784e13d24a2e97f61 to your computer and use it in GitHub Desktop.
Steps to start and manage a Django Project

Setup the Virtual Environment

For Windows users, use the following steps (you are free to use Conda environments if you want to) :

pip install virtualenv
cd my-django-project
virtualenv venv
venv\Scripts\activate.bat
pip install django

For others, follow the following steps:

pip3 install virtualenv
cd my-django-project
virtualenv venv
source venv/bin/activate
pip3 install django

Create and Manage

  • Create a new project : django-admin startproject sample
  • Create a new app : python manage.py startapp app
  • Add the app name to settings.py under INSTALLED_APPS
  • Create a urls.py file inside app
  • Link the urls.py file of the project to the urls.py file of the app
  • Create the templates, static folders
  • Add the TEMPLATES_DIR, STATICFILES_DIRS = [STATIC_DIR,] in settings.py file
  • Create the base.html, and remember to {% load static %} in every html to make use of the templating engine
  • Create the models using classes, remember to put in __str__
  • In the admin page, add these models
  • Migration time
  • Create views inside views.py, use templating to create dynamic webpages
  • Map URLs to each view you've created
  • Populate the database with faker
  • Migration time DONE!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment