[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

1,382 views
Skip to first unread message

Luigi Mognetti

unread,
Jul 16, 2017, 9:49:13 AM7/16/17
to Django users
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 :)  

Andréas Kühne

unread,
Jul 16, 2017, 1:36:29 PM7/16/17
to django...@googlegroups.com
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

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
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 all
Reply to author
Forward
0 new messages