Project Setup

  • Ensure virtual env and souce ./venv/bin/activate
  • Ensure it’s the python version wanted python --version
  • Ensure it’s the django version wanted python -m django --version
  • Create new project with django-admin startproject <name>
  • Ensure project runs with python manage.py runserver and visit the url in the output.

App Setup

From the root project folder python manage.py startapp <name>

  • Configure view (what in rails is a controller)
  • Configure URL (what in rails is a route)
  • Ensure url imported into top level

DB Setup

Ensure db engine configuration in the <appname>/settings.py file.

Then, run python manage.py migrate to run the initial migration for system apps.

Adding Models to the DB

For each app that uses a db model, once it is ready to be included in migrations, ensure it is listed under INSTALLED_APPS in the settings.py conf.

Run python manage.py makemigrations <appname> to scan the models for that app and create any migrations based on the diff.

Run python manage.py sqlmigrate <appname> <migrationN> to get a preview of the sql commands autogenerated from that migration.