Launching Django’s development server

After activating the virtual environment, you can run the below command to start the server.

python manage.py runserver

Sharing the screenshot below.

Development server

Designing a RESTful API to interact with SQLite database

In this chapter, we will create Django API views for HTTP requests and will discuss how Django and Django REST framework process each HTTP request. 

  • Creating Django Views
  • Routing URLs to Django views and functions
  • Launching Django’s development server
  • Making HTTP requests using the command-line tool
  • Making HTTP requests with Postman

Similar Reads

Creating Django Views

In the previous chapters, you have seen how to create a model and its serializer. Now, let’s look at how to process HTTP requests and provide HTTP responses. Here, we will create Django views to process the HTTP requests. On receiving an HTTP request, Django creates an HttpRequest instance and it is passed as the first argument to the view function.  This instance contains metadata information that has HTTP verbs such as GET, POST, or PUT. The view function checks the value and executes the code based on the HTTP verb. Here the code uses @csrf_exempt decorator to set a CSRF (Cross-Site Request Forgery) cookie. This makes it easier to test the code, which doesn’t portray a production-ready web service. Let’s get into code implementation....

Routing URLs to Django views and functions

...

Launching Django’s development server

Now, it’s necessary to route URLs to view. You need to create a new Python file name urls.py in the taskmanagement folder (restapi\taskmanagement) and add the below code....

Making HTTP requests using the command-line tool

...

Making HTTP requests with Postman

...

Summary

After activating the virtual environment, you can run the below command to start the server....