Micro Services Classroom Series – 19/Dec/2021

Fix for the Authorization in Swagger

  • We need to add the security scheme, for that in app.py we have added the following Preview
  • Now we have also add the necessary settings in the decorator of each API Preview
  • Now we can navigate to swagger ui-url Preview Preview Preview Preview Preview Preview
  • Refer Here for the changes

Building The Instacook using django restful framework

  • We will try to build the same insta cook application in Django restful framework as it will be easy to evaluate both the web frameworks
  • Django architecture:
    • This is based on Model-View-Template (MVT).
    • This is a design pattern for web applications Preview
  • Lets get started.
  • Create a new folder and create a virual environment and activate
  • Install django framework pip install django
  • Create a django project instacook django-admin startproject instacook
  • Refer Here for the changes
  • Refer Here for the folder
  • Now run the project from command line by executing python manage.py runserver Preview
  • Now lets configure Pycharm to run this application by create a configuration Preview
  • Now in settings.py we have some installed apps, which have predefined models, so lets migrate them so that we can use admin interface of django. Now create a super user Preview

Django Rest framework installation

  • Django restframework Refer Here for the homepage and Refer Here for the installation
  • Now lets install the djangoresframework and add the rest_framework to the installed apps
  • Now we have rest framework and django project, lets create our api for instacook
  • I will be creating an application called api_instacook
python manage.py startapp api_instacook
  • Now create a new file called as urls.py in api_instacook folder
  • Refer Here for the changes added
  • Django application have their own orm framework django-orm in the earlier project with flask we have use sqlalchemy
  • Django-orm Refer Here
  • For field types of Django-ORM Refer Here
  • Refer Here.
  • We got error in migration as by mistake i have added urls.py in the migrate folder
  • Now fixed Refer Here for changes

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin