Alexander Lamas
2018-10-18 05:12:56 UTC
Hi all,
I'm trying to find the possible best/faster way to build a lookup result
set to populate a HTML select tag (dropbox).
I have done this, but I don't think is efficient and fast.
class MyLookup(APIView):
def get(self, request, format=None):
result = []
for item in mymodel.objects.filter(isactive=True).order_by("name"):
result.append({"id": item.id, "name": item.name})
return Response(result)
Do you guys know a better way?
Also, do you guys know a way of just getting the columns I need from
database and perhaps a straight return from the queryset?
Thank you very much!
Regards,
Alex
I'm trying to find the possible best/faster way to build a lookup result
set to populate a HTML select tag (dropbox).
I have done this, but I don't think is efficient and fast.
class MyLookup(APIView):
def get(self, request, format=None):
result = []
for item in mymodel.objects.filter(isactive=True).order_by("name"):
result.append({"id": item.id, "name": item.name})
return Response(result)
Do you guys know a better way?
Also, do you guys know a way of just getting the columns I need from
database and perhaps a straight return from the queryset?
Thank you very much!
Regards,
Alex
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.