Reputation: 1287
Here is the response returned by my view in django. For some reason the web inspector recognizes that the content_type is application/json but when using httpie, it recognizes it as text/html. Am I doing something wrong, which do i trust?
Here is my view code:
def RegistrationView(request):
if request.method == 'GET':
reg_user = User.objects.create(username=str(User.objects.all().count()+1), password=str(uuid.uuid4()))
reg_user.save()
serialized_user = UserSerializer(reg_user)
json_rend = JSONRenderer()
import ast
return JsonResponse(ast.literal_eval(json_rend.render(serialized_user.data)))
return HttpResponse("woah")
Here is the comparison between httpie and the safari web inspector:
Upvotes: 0
Views: 727
Reputation: 599490
In the first screenshot, you are requesting localhost:8000/lkd/. In the second, you are requesting localhost:8000/lkd - note, no trailing slash. In that second case, Django is sending a 301 response which redirects you to the address with the slash, as the rest of that screenshot shows.
Upvotes: 5