We're going to take you step-by-step to build a modern, fully open-source,Banking System RESTful API using Python, Django Rest Framework.
This course will teach you exactly how to build one with Django, Python, Django Rest Framework, and more.
1 - Requirements: no code
Prerequisites required include:
- Python 3
- Pip 3
- Virtualenv
- Django == 3.2.9
-
Make directory in your workspace:
mkdir banksystem_project
-
Navigate into
banksystem_project
cd banksystem_project
-
Create a python virtual environment to install django and other dependecies in the future.
virtualenv .env
.env
is the directory where we install the packages. -
Activate the virtual environment.
source .env/bin/activate
-
Install Django framework. We are going to use
django==3.2.9
in this tutorial.pip3 install django==3.2.9
OR
pip install django==3.2.9
If python3 is the default version running.
-
Create django project:
django-admin startproject banksystem
That's it !!!!! You did it 😃 👏 👏
If you want to see the blank project we created follow the link below.
Now lets create an application called api
inside our project banksystem
. To learn more about django applications.
Run the following command in your root folder where manage.py
lives.
./manage.py startapp api
The app api
will be created and your whole project folder structure should look like this.
[banksystem_project]/
├── [banksystem]/
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
|____[api]/
| |__ __init__.py
| |__ models.py
| |__ views.py
| |__[migrations]/
| | |___ __init__.py
| |
| |__admin.py
| |__tests.py
|
└── manage.py
Include api
application in django settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'api',
]
Learn about django project structure.
1 - Introduction: no code
2 - Install Django Rest Framework
Install using pip
...
pip install djangorestframework====3.12.4
pip install Markdown==3.3.6 # Markdown support for the browsable API.
pip install django-filter==21.1 # Filtering support
Add 'rest_framework'
to your INSTALLED_APPS
setting in settings.py
.
INSTALLED_APPS = (
...
'rest_framework',
)
If you're intending to use the browsable API you'll probably also want to add REST framework's login and logout views. Add the following to your rooturls.py
file. Location of urls.py banksystem_project/banksystem/urls.py
urlpatterns = [
...
url(r'^api-auth/', include('rest_framework.urls'))
]
Note that the URL path can be whatever you want.
3 - Creating Bank System Models
4 - Implementing Branch & Bank Endpoints Using generic views
42 - Final wrap-up: no code