How do you handle apostrophe and spaces in dynamic url?

112 views
Skip to first unread message

Thierry

unread,
May 12, 2009, 4:10:21 PM5/12/09
to Django users
I have a table with the following names:

id name
1 Foo
2 Foo goo
3 Foo's goo

I want to use the name to construct my url. I don't have a problem
constructing Foo:

localhost/foo

But how am I supposed to handle "Foo goo" and "Foo's goo"? Will I
need to create a 3rd column just to hold the url like the following:

id name url
1 Foo foo
2 Foo goo foo-goo
3 Foo's goo foos-goo

I will also need that url to retrieve information on that entry from
the table. Can someone with a lot of experience in web dev confirm
that the above is the best way to handle this situation?

Alex Gaynor

unread,
May 12, 2009, 4:12:18 PM5/12/09
to django...@googlegroups.com
The most common practice is to have a seperate slug field, Django's SlugField for models serves to fill this exact purpose, it can only be used in conjuction with the prepopulated_fields ModelAdmin option.

Alex

--
"I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire
"The people's good is the highest law."--Cicero

George Song

unread,
May 12, 2009, 4:13:56 PM5/12/09
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages