[Django] Starting a project

less than 1 minute read

For Windows:

1. Starting up a new project

Inside the project directory(folder),

>> (myvenv) django-admin startproject myproject

2. Try running the project

After cd-ing into the myproject folder, run the local server.

>> (myvenv) python manage.py runserver

3. Database Setting (Migrations)

Django’s default database is SQLite. Migrations are Django’s method of making changes made to the models into the database.

>> (myvenv) python manage.py makemigrations
>> (myvenv) python manage.py migrate

‘makemigrations’ command creates the migrations (generates the SQL commands)

‘migrate’ command applies igrations. (executes the SQL commands)

4. Create Superuser (admin)

>> (myvenv) python manage.py createsuperuser

5. Create an app

If you want to add a functionality to your website, an app does it.

>> (myvenv) python manage.py startapp survey

In settings.py - INSTALLED_APPS, add the new app’s name.

Updated:

Leave a comment