Opened 17 years ago

Closed 17 years ago

#5368 closed (wontfix)

allow .(dot) in slug fields

Reported by: Amit Upadhyay <upadhyay@…> Owned by: amitu
Component: Uncategorized Version: dev
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Slug fields are used for url construction, and in cases when someone is switching their website to django they may want to preserve the old urls. I have done so on my blog, which was hosted blogger blog, and all urls ended with .html. Django admin does not allow me to edit the posts as slug fields do not allow dot. It should be allowed.

Attachments (2)

allow-dot.patch (168.2 KB ) - added by Amit Upadhyay <upadhyay@…> 17 years ago.
fix and documentation update.
allow_dot.patch (1.1 KB ) - added by amitu 17 years ago.

Download all attachments as: .zip

Change History (11)

by Amit Upadhyay <upadhyay@…>, 17 years ago

Attachment: allow-dot.patch added

fix and documentation update.

comment:1 by Yuri Baburov <burchik@…>, 17 years ago

If one don't use generic views, he can simply add "(?P<slug>\w+).html" in your urls.
And could you please correct end of line differences in your patch...

by amitu, 17 years ago

Attachment: allow_dot.patch added

comment:2 by amitu, 17 years ago

Owner: changed from nobody to amitu
Status: newassigned

comment:3 by amitu, 17 years ago

Has patch: set

in reply to:  1 ; comment:4 by amitu, 17 years ago

Replying to Yuri Baburov <burchik@gmail.com>:

If one don't use generic views, he can simply add "(?P<slug>\w+).html" in your urls.
And could you please correct end of line differences in your patch...

My automated import script ended up dumping data in SlugField without verification, along with ".html" in it. So it is mostly my problem and django need not necessarily be changed.

Just wondering, why is dot not allowed in slug? Its a very mainstream character in URLs.

I am +0 on this fix.

in reply to:  4 ; comment:5 by Yuri Baburov <burchik@…>, 17 years ago

Just wondering, why is dot not allowed in slug? Its a very mainstream character in URLs.

And why they should be allowed? :)

I am +0 on this fix.

Imagine you have web 2.0 tag and site did slug "web-2.0" and you have got url "/tags/web2.0/blablabla" instead of "/tags/web20/". That's fine.
But did you think about backward compatibility?
Lots of people will be required to change their slug regexps in URLconf... Including me! :(
So I am -1...

comment:6 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedDesign decision needed

in reply to:  5 ; comment:7 by anonymous, 17 years ago

Replying to Yuri Baburov <burchik@gmail.com>:

Just wondering, why is dot not allowed in slug? Its a very mainstream character in URLs.

And why they should be allowed? :)

Taking your example of tags, slug is the proper choice for the text of the tag, but people want to use .(dot) in their tag names, to not allow it on legacy/backward compatibility is just a technology quirk we are allowing to dictate a decision. Sure technological considerations are important and there is a work around, monkey patch or use your own SlugField derived class, but for the simple use case of using slug as tag, the fact that .(dot) was not allowed would be seen as a historic mistake and not as a decision taken on strong technical grounds.

But why stop at .(dot), how about the other characters? The basic idea behind slug comes from beautiful URLs, and "~ ` !@#$%&*()-_=+:;'",.?" gets translated to "%7E+%60+%21%40%23%24%25%5E%26*%28%29-_%3D%2B%3A%3B%27%22%2C.%3F" in URL, and we can see that only *(asterisk), -(hyphen), _(underscore) and .(dot) do not get mangled. We do not allow _(underline) because links are usually underlined, and its difficult to see the underline in links. This leaves us with precisely two characters: dot and hyphen (1), one is already allowed(hyphen) and I feel we should allow the other one too.

1: *(asterisk) is a mathematical symbol that people do not usually use so it may be left out, but with this line of reasoning it may be okay to allow it too.

in reply to:  7 comment:8 by Yuri Baburov <burchik@…>, 17 years ago

Replying to anonymous:

1: *(asterisk) is a mathematical symbol that people do not usually use so it may be left out, but with this line of reasoning it may be okay to allow it too.

Asterisk is also used in filesystems and may confuse site users.
Dots are used for file extensions.
Wouldn't it be strange if dots will appear in slugs when not expected?
I'm changing my mind to +0.

comment:9 by Malcolm Tredinnick, 17 years ago

Resolution: wontfix
Status: assignedclosed

I think this is all a bit of a non-issue. Slug fields are for a particular style of string. Underneath, though, they are just character fields with a validator. So if you want different validation requirements, just use a CharField and your own validator.

Note: See TracTickets for help on using tickets.
Back to Top