Hello, Recently, we are solving a conceptual question of designing clean urls for list and detail views of objects with slugs.
Let's say we have products with their slugs. In the naive way, the list view could be accessed by /products/ and the detail views could be accessed by /products/myproduct/ where "myproduct" is a slug of a product. Problems appear when you want to filter or sort list of products by different parameters, have a possibility to add another product, or have pagination. In those cases /products/by-popularity/ /products/featured/ /products/page5/ /products/add/ etc. would clash with /products/<product_slug>/ and there should be either a black list of words for <product_slugs> like del.ici.ous and flickr.com does, or there should be another way to differentiate between slugs and controlling words. In my opinion, the black-list approach is very limited and doesn't make your website extensible. So let's see what other options are. 1. One of the approaches is to use special symbols for the controlling words, which are not allowed in slugs, like in last.fm or wikipedia does. So the list urls might look like this: /products/sort-by:popularity/ /products/filter-by:featured/ /products/page:5/ /products/action:add/ /products/myproduct/ /products/myanotherproduct/ or /products/+by-popularity/ /products/+featured/ /products/+page5/ /products/+add/ /products/myproduct/ /products/myanotherproduct/ 2. Another way is to use a special symbol like a dot together with the primary key as a part of the url for product-details page, i.e.: /products/by-popularity/ /products/featured/ /products/page5/ /products/add/ /products/123.myproduct/ /products/456.myanotherproduct/ or /products/by-popularity/ /products/featured/ /products/page5/ /products/add/ /products/myproduct.123/ /products/myanotherproduct.456/ 3. Using a prefix for product details: /products/by-popularity/ /products/featured/ /products/page5/ /products/add/ /products/prod_myproduct/ /products/prod_myanotherproduct/ /products/prod_featured/ 4. Using a separate namespace for product details: /products/by-popularity/ /products/featured/ /products/page5/ /products/add/ /products/product/myproduct/ /products/product/myanotherproduct/ or /products/by-popularity/ /products/featured/ /products/page5/ /products/add/ /products/details/myproduct/ /products/details/myanotherproduct/ or /products/by-popularity/ /products/featured/ /products/page5/ /products/add/ /products/unit/myproduct/ /products/unit/myanotherproduct/ 5. Using upper case for controlling words: /products/BY-POPULARITY/ /products/FEATURED/ /products/PAGE5/ /products/ADD/ /products/myproduct/ /products/myanotherproduct/ 6. Using plural for managing lists and using singular for managing details: /products/by-popularity/ /products/featured/ /products/page5/ /products/add/ /product/myproduct/ /product/myanotherproduct/ 7. Using the controlling words before the type of list: /by-popularity/products/ /featured/products/ /page5/products/ /add/products/ /products/myproduct/ /products/myanotherproduct/ What approaches do/would you use and why? What would be best for a future-proof website? Are there any valuable resources about URL design? --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---