Thank you, you are right: I installed django-sslify 
<https://github.com/rdegges/django-sslify> some time ago.

I have to make my request with secure=True:

response = c.post("/mybackend/favorites/cookbook/", data={"name": 
"cookbook_1"}, secure=True)

I furthermore added a test which checks, that a request without secure=True 
gets a redirect as answer. Bam! :)

Am Mittwoch, 25. Mai 2016 17:12:26 UTC+2 schrieb Xavier Ordoquy:
>
> Hi,
>
> Le 24 mai 2016 à 23:27, 'JS' via Django REST framework <
> [email protected] <javascript:>> a écrit :
>
> Hello,
>
> I try to test a BasicList View with the api client:
>
> c = APIClient()
>
> response = c.post("/mybackend/favorites/cookbook/", data={"name": 
> "cookbook_1"})
>
>
> But my response is a django.http.response.HttpResponsePermanentRedirect, 
> and 
>
> response.url
>
> is a redirect to:
> https://testserver:443/mybackend/favorites/cookbook/
>
> I expect to get a HTTP 201 created, and when I call my api on a django 
> testserver with curl, exactly this happens. Why does the API Client want to 
> redirect somewhere?
>
>
> The API Client doesn’t do that. It’s your project that does it.
> You probably have some settings or middleware to force the redirection to 
> https.
>
> Regards,
> Xavier,
> Linovia.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to