I'm a little unclear as to what change you are proposing. The URLconf
is entirely under the control of the end user. If you don't like
trailing slashes, then don't use them. Django provides the
APPEND_SLASH option as a way to interpret the 'missing slash' on users
URLs, but if you set up your URLs to avoid the need for the trailing
slash, then you have no need for the APPEND_SLASH option at all.
So - what exactly are you proposing that we change in Django?
Looking at your proposal as a purely end-user suggestion: using
'hello/*$' means that hello////// will match your URL pattern.
'hello/?$' would be a safer match, as it would only match a single
trailing slash.
However, it still wouldn't be a good idea to deploy this pattern. Some
search engines (Google being a notable and prominent example) penalize
websites that post identical content on multiple different URLs, as
this is a common marker of SEO spam. Deploying hello/*? or hello/?$
means that multiple URLs will serve the same content. Problems with
trailing slashes notwithstanding, the APPEND_SLASH approach uses a
redirect, which doesn't attract the same 'Google penalty'.
Yours,
Russ Magee %-)
This statement is wholly inaccurate. Those URLs are only the same to
Django in the case where a rule is written to accept them that way,
and the webserver above is nice about the treatment of them. Take
this example:
urlpatterns = patterns('',
(r'hello', 'view1'),
(r'hello/', 'view2'),
)
Those are most definitely the same, and this is by choice and by user
convention. I am a strong -1 to your ideas about not making slash
default, or that anything here is a /. If APPEND_SLASH was a hack,
then why does every webserver have equivalent functionality to emulate
the add a trailing / behavior?
gav
As Russ already said -- did you read his post? -- this is already *up
to you*. If you want trailing slashes to be optional:
1. Set APPEND_SLASH to False.
2. Write your urlconfs with optional slashes.
3. There is no step three.
Django itself makes no assumptions about how you'd like to design your
URLs. Behavior like APPEND_SLASH and PREPEND_WWW are shortcuts for
common desires, but both are incredibly easy to disable.
Why don't you back up a step: What are you trying to do that isn't working?
Jacob
I think that's the basic hang-up you're running into here: we don't
really do that kind of development. Every single piece of code in
Django exists because someone -- often lots of people -- have a
concrete problem in a real-world application. We don't write code
speculatively, nor do we care to spend a lot of time debating style.
Trailing slashes versus non-trailing is a design issue, and as long as
Django's allowing both styles you're not going to get a lot of
traction suggesting that Django somehow "solve" the question.
Jacob