[1.8 to 1.10] Why I had to set trailing slash to false in my DRF urls.py in order to make things work like before the update

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[1.8 to 1.10] Why I had to set trailing slash to false in my DRF urls.py in order to make things work like before the update

Luigi Mognetti
Hi,

I was running on 1.8, using django mainly for his API with DRF. 
Everything worked well. 
Since I went on with 1.10 I have this kind of message when I make a PUT request to my API : 

You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to 127.0.0.1:8000/X/2304/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.



 I set trailingslash=False in my default router in Urls.py and now it works. Why ?

Thank you for your time :)  

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fce9fba6-5749-468a-b46b-164b300bda4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [1.8 to 1.10] Why I had to set trailing slash to false in my DRF urls.py in order to make things work like before the update

Andréas Kühne
Hi,

I think the error message is pretty self explaining. You are using DRF - what are you using for the frontend? Which URLs are being called? By default all django urls should end in a trailing slash - for example : /posts/1/ and if you are calling these from a django template page this is automatically taken care of with the "url" template tag. However if you are using DRF and not adding the trailing slash - you will get the warning that you received.

My tip would be to go through the frontend code and search for calls that don't include a trailing slash.

Regards,

Andréas

2017-07-16 11:05 GMT+02:00 Luigi Mognetti <[hidden email]>:
Hi,

I was running on 1.8, using django mainly for his API with DRF. 
Everything worked well. 
Since I went on with 1.10 I have this kind of message when I make a PUT request to my API : 

You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to 127.0.0.1:8000/X/2304/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.



 I set trailingslash=False in my default router in Urls.py and now it works. Why ?

Thank you for your time :)  

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fce9fba6-5749-468a-b46b-164b300bda4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCdAeXueTf6r20PU-p5h-p4-4%3DeEY4E-2nTTnry1iX9UVg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...