Skip to content

elmar8287/django-backend-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SETUP

  • Install Python last version
  • check Python3 version - python3 --version
  • check pip3 version - pip3 --version
  • if need update it python3 -m pip install --upgrade pip
  • Could be used also brew install pip
  • python3 -m pip install Django
  • django-admin startproject api - to create the project
  • cd api
  • pip install pylint - Setup linters for Mac (here is the link)
  • python3 manage.py migrate - make first migration, it is mondatory to create the db.sqlite3
  • python3 manage.py startapp rest_api - create the app
  • Add 'rest_api', into INSTALLED_APPS in settings.py file
  • python3 manage.py createsuperuser - creating of super user (remember username/pass for future)
  • python3 manage.py runserver - to run server on localhost
  • go to localhost:8000/admin and you will see login page to admin dashboard

MODELS

  • In models.py file add the model
  • Register this model in admin.py file
  • Migrate by python3 manage.py makemigrations and then python3 manage.py migrate
  • Now we can add a single item to db from admin panel

Setup Django REST Framework

  • pip install djangorestframework - install the framework
  • Add 'rest_framework', into INSTALLED_APPS in settings.py file
  • Add serializers
  • Add view for serializers
  • Add urls

Heroku deploy

  • heroku --version check you version
  • heroku login - to login to your account
  • heroku create [name of your app] - create an app on your heroku account
  • echo python-3.10.2 > runtime.txt
  • git add runtime.txt
  • echo "web: python manage.py runserver 0.0.0.0:$PORT" > Procfile
  • git add Procfile
  • heroku git:remote -a az-courses-api
  • heroku buildpacks:set heroku/python
  • python -m pip freeze
  • python -m pip freeze > requirements.txt
  • heroku config:set DISABLE_COLLECTSTATIC=1
  • git push heroku branch_name:main
  • ALLOWED_HOSTS = ['*'] in your settings.py

About

This project is about how to setup the Django Rest Framework. Here you can also familiar with deployment on Heroku cloud.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages