Export Data from QuerySet as Excel File in Django
Let's say you have this function in your views.py: def funtion_name(request): if request.method == "GET": get_id = request.user.id ... ... ... args = [] kwargs = { 'landproperty__sownerid__id': get_id, 'geom__distance_lte': (pnt, D(km=kmdistance)), 'narea__lte': getarea } mm = YourModelHere.objects.filter(*args, **kwargs).values_list('fielname1', 'fielname2', 'fielname3','fielname4') request.session[0] = mm return HttpResponse(json.dumps(list(m)), content_type='application/json') In order to get or pass the QuerySet from this function, you need to store it in a session as shown above. Here's how to create an excel file: def create_excel(request): book = xlwt.Workbook(encoding='utf8') sheet = book.add_sheet('untitled') default_style = xlwt.Style.defa...