django - REST REQUEST not returning correct response -
i'm new rest , have been working on using requests (python), django, , django rest framework. trying make request returns objects "priority" (int field) value of 4. problem query doesn't seem working , request returning project objects. structure looks correct , i'm able change pages using exact same syntax i'm not sure i'm doing wrong. here think you'd need, awesome. thanks!
generated url = http://127.0.0.1:8000/api/projects/?priority=4
restconnect.py{
local = 'http://localhost/' base = 'http://127.0.0.1:8000/api/' def sign_in(current_user, username, password): response = current_user.get(base + 'api-auth/login/', auth=(username, password)) print response print response.url print response.reason # of intentionally generic , little rough (the way session being passed) def find_priority(current_user, username, password): find_projects = {"priority": "4"} response = current_user.get(base + 'projects', params=find_projects, auth=(username, password)) print response print response.url print response.text
}
querytest.py {
import requests import restconnect current_user = requests.session() restconnect.sign_in(current_user, 'user', 'password') restconnect.find_priority(current_user, 'user', 'password')
}
serializer.py {
from rest_framework import serializers, viewsets import django_filters . models import project class projectfilter(django_filters.filterset): class meta: model = project fields = ['name', 'status', 'priority'] class projectserializer(serializers.hyperlinkedmodelserializer): class meta: model = project class projectviewset(viewsets.modelviewset): queryset = project.objects.all() serializer_class = projectserializer filter_class = projectfilter
}
Comments
Post a Comment