Tutorial on django2 backend and angular6 frontend blog webapp and delpoying on heroku
This Repository contains Django as backend and Angular as frontend together in a blog web application including a custom django user model and serving the angular directly from django views and finally deploying the project to Heroku
-
Create virtualenv by directly installing the packages using pipenv
pipenv install django djangorestframework djangorestframework-jwt python-decouple
-
Activate the virtualenv using (run the next commands in activated virtualenv)
pipenv shell
-
Start django Project
django-admin startproject backend .
trailing dot at end tell django to create files in the current folder
-
Create apps for django
python manage.py startapp accounts python manage.py startapp blogs
-
Add apps in backend/settings.py
INSTALLED_APPS
list
INSTALLED_APPS = [
# django apps
'accounts',
'blogs',
# django packages
'rest_framework',
]
Configure django rest framework and rest framework JWT authentication by adding
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
),
}
- I assume that you have NodeJS and Angular CLI already installed on your local machine