I have 5 different Foreign Key values in 1 model. There are 1800 records in total.
Using AJAX it is necessary to convert the data to JSON format. I can do this with the Serializers library. I use use_natural_foreign_keys = True for Foreign Key values to return string values.
use_natural_foreign_keys = True
- When i use it; 15 seconds of query
- When I am not using it; 0.5 second
But I have to use it. Otherwise, I cannot get Foreing Key values when converted to JSON format.
I leave the query here. How can I make queries faster? Thanks in advance.
result=AbcModel.objects.all()
if kapanan_talepler:
jsons=serializers.serialize('json',result, use_natural_foreign_keys=True)