> I am writing an application that involves a number of nested parent- > child relationships, where users create objects that each in turn have > sub-objects. So far the URL structure looks like this: > > example.com/username/ > example.com/username/child1/, example.com/username/child2/ > example.com/username/child2/grandchild1, example.com/username/child2/ > grandchild2 > > As you could guess, keyworded URL parameters are used to filter > through each level of this structure. Usernames in Django are case- > sensitive; I think it could be a real problem to have case sensitive > urls, something like example.com/Bob/widget1 and example.com/bob/ > widget1, leading to user confusion. I can think of two ways to > circumvent this: > 1) Have an uneditable SlugField in a UserProfile that is saved when > the account is created that would save the username as > username.lower(); > 2) Validate new usernames for case-insensitive uniqueness and filter > with case-insensitive queries whenever the username is URL param. > > My hope is that there is a magically third option (I wouldn't consider > a patch very magical), but if not, which of these options is better? > My guess is the first.
I'd opt for the second; there won't be no need for an extra field in eg the admin view (potentially confusing other admins). Besides, unless I understand your problem incorrectly, it would be easy to transform the username to lower case and use that throughout your view (and models). You catch it once in your args/kwargs in the first line (definition) of your view, than transform it: def view(request, username, child=None, ...): username = username.lower() <continue without worrying about case-insensitive filtering> Perhaps there is a way to even do this at the URL level (in the regex?), but I wouldn't know. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---