Django json parser

23 views
Skip to first unread message

bharat pamnani

unread,
May 30, 2020, 9:12:07 AM5/30/20
to Django users
I am a beginner in django and i need to build an app which enter some user data and their activity period by creating model i can do that to store in sql database.
The problem is i need to display that data in json format any help will be really appreciated 

Thanks

HJ

unread,
May 30, 2020, 10:07:39 AM5/30/20
to Django users
you have to do a Queryset inside your view function , something like :

@login_required
def Home(request):
 return render(request,'home.html',{})

@login_required
def JsonFunction(request):
 dataset = YourModel.objects.all()
 data = list(dataset)
 return JsonResponse(data, safe=False)

that's only an example you need to set what you want to show 
Reply all
Reply to author
Forward
0 new messages