/Django-Angular-Blog

Tutorial on django2 backend and angular6 frontend blog webapp and delpoying on heroku

Primary LanguageJavaScript

Django-Angular-Blog

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

Initial Setup

  1. Create virtualenv by directly installing the packages using pipenv

    pipenv install django djangorestframework djangorestframework-jwt python-decouple
    
  2. Activate the virtualenv using (run the next commands in activated virtualenv)

    pipenv shell
    
  3. Start django Project

    django-admin startproject backend .
    

    trailing dot at end tell django to create files in the current folder

  4. Create apps for django

    python manage.py startapp accounts
    python manage.py startapp blogs
    
  5. 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',
    ),
}
  1. I assume that you have NodeJS and Angular CLI already installed on your local machine