How to Convert Models Data into JSON in Django ? Last Updated : 16 Mar, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Django is a high-level Python based Web Framework that allows rapid development and clean, pragmatic design. It is also called batteries included framework because Django provides built-in features for everything including Django Admin Interface, default database SQLlite3, etc. How to Convert Models Data Into Json Data In Django ? First create new project django-admin startproject tryJsoncd tryJson Then create new app inside your project python manage.py startapp main Add your main app inside the tryJson/settings.py in INSTALLED_APPS Edit the models.py in main app Python3 from django.db import models class Student(models.Model): course_choices = ( ('1','Java'), ('2','Python'), ('3','Javascript') ) name = models.CharField(max_length=50) rollno = models.IntegerField() course = models.CharField(max_length=15, choices = course_choices) Then to create model we have to write below commands in cmd or terminal python manage.py makemigrationspython manage.py migrate So we have created our model Students with some fields like name , roll no , course. Insert Some data into model. Create a new file inside your main app urls.py Python3 from django.urls import path from . import * urlpatterns = [ path("",views.jsondata,name = "jsondata"), ] Write logic to convert models data into Json data views.py Python3 from django.http import JsonResponse from .models import Students def jsondata(request): data list(Students.objects.values()) return JsonResponse(data,safe = False) Use values() method to get all the data and convert into list using list() function and store in a variable.return a JsonResponse and pass the data and put safe = False Then open cmd or terminal to run this app python manage.py runserver Output :- Comment More infoAdvertise with us Next Article How to Add Data from Queryset into Templates in Django V vivekpisal12345 Follow Improve Article Tags : Python Web Technologies Python Django JSON Django-models Python Framework +2 More Practice Tags : python Similar Reads How to Render Data in Django Django's render() function is a fundamental tool for building dynamic web applications. It simplifies the process of combining HTTP requests with HTML templates and dynamic data, making it easier for developers to create interactive and data-driven web pages. What is render()?In Django, the render( 3 min read How to Import a JSON File to a Django Model? In many web development projects, it's common to encounter the need to import data from external sources into a Django application's database. This could be data obtained from APIs, CSV files, or in this case, JSON files. JSON (JavaScript Object Notation) is a popular format for structuring data, an 3 min read How to Add Data from Queryset into Templates in Django In this article, we will read about how to add data from Queryset into Templates in Django Python. Data presentation logic is separated in Django MVT(Model View Templates) architecture. Django makes it easy to build web applications with dynamic content. One of the powerful features of Django is fet 3 min read How to get JSON data from request in Django? Handling incoming JSON data in Django is a common task when building web applications. Whether you're developing an API or a web service, it's crucial to understand how to parse and use JSON data sent in requests. In this article, we will create a simple Django project to demonstrate how to retrieve 2 min read How to Clone and Save a Django Model Instance to the Database In the realm of web development, Django stands out as a robust and versatile framework for building web applications swiftly and efficiently. One common requirement in Django projects is the ability to clone or duplicate existing model instances and save them to the database. This functionality is p 3 min read How to Convert a Django QuerySet to a List? Converting a Django QuerySet to a list can be accomplished using various methods depending on your needs. Whether you want a list of model instances, specific fields, IDs, or serialized data, Django provides flexible ways to achieve this. Understanding these methods will help you effectively work wi 3 min read Like