VOOZH about

URL: https://www.geeksforgeeks.org/python/concrete-genericapiviews-in-django-rest-framework/

โ‡ฑ Concrete GenericAPIViews in Django Rest Framework. - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Concrete GenericAPIViews in Django Rest Framework.

Last Updated : 23 Jul, 2025

Django Rest Framework (DRF) provides powerful tools for building RESTful APIs in Django projects. One of the key components of DRF is Concrete GenericAPIViews, which offer pre-implemented views for common CRUD (Create, Read, Update, Delete) operations. In this article, we will see Concrete GenericAPIViews in Django Rest Framework.

What is Concrete GenericAPIViews in Django?

Concrete GenericAPIViews in Django are pre-defined view classes that simplify the creation of RESTful APIs by providing ready-to-use functionalities for common HTTP methods like GET, POST, PUT and DELETE. They include classes like ListAPIView, CreateAPIView, RetrieveAPIView, UpdateAPIView, and DestroyAPIView, reducing the need for writing repetitive code.

Concrete GenericAPIViews in Django Rest Framework

Below, are the Implementation of Concrete GenericAPIViews in the Django Rest Framework in Python:

Starting the Project Folder

To start the project use this command

django-admin startproject bookstore
cd bookstore

To start the app use this command

django-admin startapp books

Now add this app to the โ€˜settings.pyโ€™

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"books",
"rest_framework",
]

For install the Django rest_framework use the below command

pip install djangorestframework

File Structure

๐Ÿ‘ sdnfjhs
File Structure

Setting Necessary Files

books/models.py: Define the Book model as follows:

books/serializers.py : Create a file named serializers.py and define the Book serializer.

books/views.py : Create a file named views.py and define the views for handling CRUD operations:

books/urls.py : Define the URLs for the views using the following code:

bookstore/urls.py: Include the URLs of the books app using the following code.

Deployment of the Project

Run these commands to apply the migrations:

python3 manage.py makemigrations
python3 manage.py migrate

Run the server with the help of following command:

python3 manage.py runserver

Output

๐Ÿ‘ Post-Django
Post Concrete GenericAPIViews in Django


๐Ÿ‘ get-Django
Get Concrete GenericAPIViews in Django

Video Demonstration

Comment
Article Tags: