I am creating my first Django project . I have taken 30,000 values as input and want to show particular values according to primary key .
Code:
class employeesList(APIView):
def get(self,request):
employees1 = employees.objects.all()
with open('tracking_ids.csv') as f:
reader = csv.reader(f)
for row in reader:
_, created = employees.objects.get_or_create(
AWB=row[0],
Pickup_Pincode=row[1],
Drop_Pincode=row[2],
)
serializer = employeesSerializer(employees1 , many=True)
return Response(serializer.data)
def post(self,request):
# employees1 = employees.objects.get(id=request.employees.AWB)
employees1 = employees.objects.all()
serializer = employeesSerializer(employees1 , many=True)
return Response(serializer.data)
If I enter http://127.0.0.1:8000/employees/ in URL , I get all the values . I want the URL to be like http://127.0.0.1:8000/employees/P01001168074 and show values of P01001168074 where P01001168074 is primary ID .
I have read 1:showing the model values of specific user django 2)editing user details in python django rest framework but they are different
Can it be done and if it can , then how ?