Python and Django – Basics

Some notes from my Django travels so far…

Virtual Environment

In Windows:

python -m venv .\venv
.\venv\Scripts\activate

To generate a requirements.txt file for the specified project:

pip install pipreqs
pipreqs /path/to/project

Django

Install:

pip install django

Create project:

django-admin startproject <PROJECT_NAME>

Run server (127.0.0.1:8000):

python manage.py runserver

Start app:

python manage.py startapp <APP_NAME>

Make migrations:

python manage.py makemigrations

Migrate:

python manage.py migrate

Create Super User

python manage.py createsuperuser

Leave a Reply

Your email address will not be published. Required fields are marked *