Creating a New Project
Command:
django-admin startproject projectname .
Start Django base project folder. This folder will have setting.py to configure the apps and settings of the project. wsgi.py for spinning up. Then you have the urls.py to startup the routing between apps or whatever you want to do.
Create an app for the Project
Command:
python3 manage.py startapp appname
This command will create app for whatever you want to do. It will be named whatever you put in the appname location. Make sure to add this to the settings.py file under installed_apps or you are going to have a bad time.
Create Migrations
Command:
python3 manage.py makemigrations
Add changes from the models to write to the database
Push changes to database
Command:
python3 manage.py migrate
This pushes the changes to the database. When setting up a new project if you want into the admin portal make sure you do this on start. The test server will notify you that this command needs to be ran.
Start Development Server
Command:
python3 mange.py runserver
This will launch a dev server for django testing. Restart this server after big changes or any change if you want to be safe. Tools like Pycharm will do this for you.
Create Super User
Command:
python3 mange.py createsuperuser
This creates a superuser for the admin panel.
Collect Static Files
Command:
python3 manage.py collectstatic
Collects static files and puts them into one folder.
Database Commands
CREATE DATABASE yourdatabasename;
CREATE USER djangodatabaseuser WITH PASSWORD 'somepassword';
GRANT ALL PRIVILEGES ON DATABASE yourdatabaename TO djangodatabasename;
\q