Bug or Feature: Trailing Slash appended to two places in a URL

37 views
Skip to first unread message

Conor

unread,
Oct 19, 2019, 6:07:48 PM10/19/19
to Django users
Hi All,

I'm not sure whether this is a feature or a bug, so I thought it best to air it here before filing a bug report.

In short I have a URL which will be '/api/v1/case/' if APPEND_SLASH false True, or '/api/v1 case' if APPEND_SLASH = False.

To reproduce this, I have a project urls.py file with the following

 path('api/v1', include('api.urls')) - (note there is no trailing slash)

And an api/urls.py with the following

path('case', CasesView.as_view(), name='all-cases'),

What I assume is happening is that my complete URL is made up of two URLs, namely the first URL from the project urls.py file and the second URL from api/urls.py, and that the method that append's a slash to URLs is appending a slash to both of them. If you have APPEND_SLASH to True, then the URL is accessible via '/api/v1/case/' or '/api/v1/case', but if it APPEND_SLASH is False, then the URL becomes '/api/v1 case'

The thing that makes me think that perhaps this isn't a bug, is that I seemingly just didn't configure Django properly. It could be as simple as that.

However, the reason I think this is a bug, is that the behaviour, at least to me is non-obvious. That's not to say when you stop and think about it that it isn't perhaps logical, if indeed there are two URLs which have slashes appended to them in order to make the final URL, but on first glance when I read about Django's APPEND_SLASH feature, I think of the final URL, the one that the user will see, not of two separate URLs  that are being put together to make the final product.

Please let me know your thoughts and if you think it is a bug or not.

Cheers,

Conor

lemme smash

unread,
Oct 21, 2019, 11:13:11 AM10/21/19
to Django users
i'm not sure, but i can say that it's quite strange not to have trailing slash on `include` path. you want to have something like `api/v1case`?

Conor

unread,
Oct 21, 2019, 1:23:27 PM10/21/19
to Django users
I want the url to be /api/v1/case. I have no problem building that URL, it's just that due to a config error on my behalf that I discovered this unusual behaviour.

Two things strike me as particular strange. The first thing is the difference between how the URL is rendered depending on whether APPEND_SLASH is True or False, and the second is where does the space come from in the rendered URL when APPEND_SLASH is False.

Anyway, to make a long story short I have submitted a bug report. I'll update this thread when I get an answer.

Cheers,

Conor
Reply all
Reply to author
Forward
0 new messages