[Answered ]-Add some data to db response in Django

2👍

Add the variable to your result_list and your fields list.

import time
result_list = list(chain(orders, alldata,
                         (time.asctime(time.localtime()),))
                  ) #or other time function
msg = serializers.serialize("json", result_list,
                            fields=("field1", "field2", "field3", "field4", "time"),
                            use_natural_keys=True)

Or, if you don’t want to add the time to the JSON object, HTTPResponse(msg) already sets the Date parameter in the Http Response header.

👤Dave

Leave a comment