May 25, 2010

Faking URL values

Let's say we have a shop, with product urls looking like this:

http://myshop.com/motorbikes/choppers
http://myshop.com/bikes/bmx
http://myshop.com/skates/aggresive

But also we have a page for top selling products:

http://myshop.com/topsellers

, that uses the same view:
def products_list(request, parent_category, child_category):
How we can avoid writing another view for top sellers, that don't send either parent_ or child_ categories in URL's ?
urlpatterns = patterns('',
    (r'^topsellers/$', views.products_list, {'parent_category': 'topsellers', 'child_category': 'topsellers'}),
    (r'^(?P\w)/(?P\w)/$', views.products_list),
)

Also I've taken request to create application for simple management of orders, stocks, warranty operations from some hospital-stuff oriented company. So generally in about two months I need to learn how to write market-ready applications in python, with generating pdf's. I'm still not sure if that was a good idea (but you know how it is when pal asks you to do him a favour - especially if he is your former boss :P ).

2 comments: