simple-RESTful-API-Django

simple-RESTful-API-Django

A simple experience about RESTful API with Django.

If you want to have an experience on RESTful API with Django. This is a full guide for you.First you need to know, I did this project using a youtube video on this link. Also, you can follow steps here and use the code in the repository.

Start from here

  1. Download python from www.python.org
  2. Download Django web framework from www.djangoproject.com, or using pip (Python built-in package installer).
  3. Create the virtual environment using Terminal: $ python3 -m venv [name]
  4. Goninto the virtual environment using Terminal: $ source [name]/bin/activate
  5. Install Django using Terminal: $ pip install django
  6. Create a project using Terminal: $ django-admin startproject [name]
  7. Go into the folder using Terminal: $ cd [project-name]
  8. Run django using Terminal: $ python manage.py runserver
  9. Create an app in teh project folder using Terminal: $ django-admin startapp [name]
  10. Go to python_api/python_api/setting.py, add the app-name in INSTALLED_APPS. (e.g. ‘myapp’)
  11. In python_api/myapp/models.py add our model. you can copy from this repo.
  12. Convert the model that you made, into a SQL table using Terminal: $ python manage.py makemigrations
  13. Do the same convertation for the app too, using Terminal: $ python manage.py makemigrations myapp
  14. Finish the previous step by run this command on terminal: $ python manage.py migrate
  15. In python_api/python_api/urls.py add our api urls. you can copy from this repo.
  16. In python_api/myapp/views.py add our logic API and codes. you can copy from this repo.
  17. Now, you can test your APIs, just don’t forget to run this command before testing: $ python manage.py runserver

Notes

  • At the end you will have two folder. the folder that hold our projects code titled as the name that choose for the project, and a folder as virtual environment to hold all of dependencies.
  • The project name in this repo is python_api
  • The app name in this repo is myapp

Visit original content creator repository

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *