Skip to content

Creating Django Project and App

Part 3 of 8 in the series Django REST Framework

Assuming you have python environment we created in last post already activated, let’s go ahead and create Django Project and App for our REST API example.

(venv) $ mkdir backend
(venv) $ cd backend

# Create Django Project called "restapi"
(venv) $ django-admin startproject restapi
(venv) $ cd restapi/

#Inside "restapi" directory, Create Django App called "quotes"
(venv) $ django-admin startapp quotes

(venv) $ cd ..
(venv) $ pwd
(venv) $ find .

Now sync the database for the first time.

(venv) $ cd restapi/
(venv) $ ls       quotes          restapi
(venv) $ python migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying sessions.0001_initial... OK
(venv) $ ls
db.sqlite3       quotes          restapi
(venv) $ 

Django by-default uses sqllite3 and you can see after DB sync, db.sqlite3 is created.

Let’s create superuser also, we’ll authenticate with that user later.

(venv) $ python createsuperuser --email --username admin
Password (again): 
This password is too common.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.
(venv) $ 

Now let’s add our app “quotes” and rest_framework app in INSTALLED_APPS settings. This way we are are telling django which apps are available. “rest_framework” is for Django-REST-Framework library which we are going to use mainly for our API interface.

“quotes” is the name of app we created. Replace it with whatever name you have used for your app.

(venv) $ vi restapi/ 
# Add "rest_framework" and "quotes" in INSTALLED_APPS list.
# Make sure about comma after last entry.
Example :


You can get all the files related to the examples here :

In next post, we will create DB models and Serializers .

Series Navigation<< Installing Django Rest Framework on macOSDjango REST Framework – Models and Serializers >>
Published inDjango

One Comment

  1. Great content! Super high-quality! Keep it up! 🙂

Leave a Reply

Your email address will not be published.

%d bloggers like this: