Re: Setting up my application
Just put those other one urls before the catch-all, for example: ... (r'^aboutus/', 'views.aboutus'), (r'^history/', 'views.history'), (r'^contactinfo/', 'views.contactinfo'), (r'(?P\w+)/', 'views.whatever), ... Greg wrote: > Duc, > Because sometimes the word will be be a manufacturer. Some example > possible url's of my site could be: > > www.mysites.com/milliken/ > www.mysites.com/mohawk/ > www.mysites.com/aboutus/ > www.mysites.com/history/ > www.mysites.com/contactinfo/ > > So sometimes it wouldn't be a manufacturer. How would I solve that > problem? > > > On May 19, 11:55 pm, Duc Nguyen <[EMAIL PROTECTED]> wrote: >> Why can't it just be a "catch-all" url like: >> >> (r'(?P\w+)/', 'theview') >> >> and then in your view: >> >> def theview(request, manufacturer): >> if manufacturer in my_manufacturers: >>do_something() >> else: >># error out with unknown manufacturer msg? >> >> >> >> Greg wrote: >>> I'm working on creating an e-commerce site in Django. I have a >>> website that sells area rugs from 20 different manufacturers. I am >>> wondering what the best way to configure my urls.py file. I've been >>> thinking of a couple of different ways to accomplish this. >>> 1) Contained all in one url line >>> (r'^(mohawk|milliken|shaw|sphinx|etc...))/$', 'theview'), >>> My 'theview' function would then find out what variable was passed to >>> it. And then query that manufacturer table. So my url can get >>> pretty long depending on how many manufacturers I have. Also, if I >>> did it this way how would I setup my view? Would it be something like >>> this >>> def theview(request, manufacturer): >>>rec = manufacturer.objects.all() >>>return render_to_response('dispaly_manu.html', {'manu_records': >>> rec}) >>> 2) Creating a separate url for each manufacturer >>> (r'^/mohawk/$', 'django.views.generic.list_detail.object_list', >>> mohawk_dict), >>> (r'^/milliken/$', 'django.views.generic.list_detail.object_list', >>> milliken_dict), >>> (r'^/shaw/$', 'django.views.generic.list_detail.object_list', >>> shaw_dict), >>> (r'^/sphinx/$', 'django.views.generic.list_detail.object_list', >>> sphinx_dict), >>> This way seems like a waste. Would I need to create a unique >>> dictionary for each manufacturer? Is there a way I can use the same >>> dictionary for every manufacturer? >>> Or does somebody have a better solution than what I came up with >>> above? >>> Thanks- Hide quoted text - >> - Show quoted text - > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Setting up my application
Duc, Because sometimes the word will be be a manufacturer. Some example possible url's of my site could be: www.mysites.com/milliken/ www.mysites.com/mohawk/ www.mysites.com/aboutus/ www.mysites.com/history/ www.mysites.com/contactinfo/ So sometimes it wouldn't be a manufacturer. How would I solve that problem? On May 19, 11:55 pm, Duc Nguyen <[EMAIL PROTECTED]> wrote: > Why can't it just be a "catch-all" url like: > > (r'(?P\w+)/', 'theview') > > and then in your view: > > def theview(request, manufacturer): > if manufacturer in my_manufacturers: >do_something() > else: ># error out with unknown manufacturer msg? > > > > Greg wrote: > > I'm working on creating an e-commerce site in Django. I have a > > website that sells area rugs from 20 different manufacturers. I am > > wondering what the best way to configure my urls.py file. I've been > > thinking of a couple of different ways to accomplish this. > > > 1) Contained all in one url line > > (r'^(mohawk|milliken|shaw|sphinx|etc...))/$', 'theview'), > > > My 'theview' function would then find out what variable was passed to > > it. And then query that manufacturer table. So my url can get > > pretty long depending on how many manufacturers I have. Also, if I > > did it this way how would I setup my view? Would it be something like > > this > > > def theview(request, manufacturer): > >rec = manufacturer.objects.all() > >return render_to_response('dispaly_manu.html', {'manu_records': > > rec}) > > > 2) Creating a separate url for each manufacturer > > (r'^/mohawk/$', 'django.views.generic.list_detail.object_list', > > mohawk_dict), > > (r'^/milliken/$', 'django.views.generic.list_detail.object_list', > > milliken_dict), > > (r'^/shaw/$', 'django.views.generic.list_detail.object_list', > > shaw_dict), > > (r'^/sphinx/$', 'django.views.generic.list_detail.object_list', > > sphinx_dict), > > > This way seems like a waste. Would I need to create a unique > > dictionary for each manufacturer? Is there a way I can use the same > > dictionary for every manufacturer? > > > Or does somebody have a better solution than what I came up with > > above? > > > Thanks- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Setting up my application
Why can't it just be a "catch-all" url like: (r'(?P\w+)/', 'theview') and then in your view: def theview(request, manufacturer): if manufacturer in my_manufacturers: do_something() else: # error out with unknown manufacturer msg? Greg wrote: > I'm working on creating an e-commerce site in Django. I have a > website that sells area rugs from 20 different manufacturers. I am > wondering what the best way to configure my urls.py file. I've been > thinking of a couple of different ways to accomplish this. > > 1) Contained all in one url line > (r'^(mohawk|milliken|shaw|sphinx|etc...))/$', 'theview'), > > My 'theview' function would then find out what variable was passed to > it. And then query that manufacturer table. So my url can get > pretty long depending on how many manufacturers I have. Also, if I > did it this way how would I setup my view? Would it be something like > this > > def theview(request, manufacturer): >rec = manufacturer.objects.all() >return render_to_response('dispaly_manu.html', {'manu_records': > rec}) > > 2) Creating a separate url for each manufacturer > (r'^/mohawk/$', 'django.views.generic.list_detail.object_list', > mohawk_dict), > (r'^/milliken/$', 'django.views.generic.list_detail.object_list', > milliken_dict), > (r'^/shaw/$', 'django.views.generic.list_detail.object_list', > shaw_dict), > (r'^/sphinx/$', 'django.views.generic.list_detail.object_list', > sphinx_dict), > > This way seems like a waste. Would I need to create a unique > dictionary for each manufacturer? Is there a way I can use the same > dictionary for every manufacturer? > > Or does somebody have a better solution than what I came up with > above? > > Thanks > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Setting up my application
I'm working on creating an e-commerce site in Django. I have a website that sells area rugs from 20 different manufacturers. I am wondering what the best way to configure my urls.py file. I've been thinking of a couple of different ways to accomplish this. 1) Contained all in one url line (r'^(mohawk|milliken|shaw|sphinx|etc...))/$', 'theview'), My 'theview' function would then find out what variable was passed to it. And then query that manufacturer table. So my url can get pretty long depending on how many manufacturers I have. Also, if I did it this way how would I setup my view? Would it be something like this def theview(request, manufacturer): rec = manufacturer.objects.all() return render_to_response('dispaly_manu.html', {'manu_records': rec}) 2) Creating a separate url for each manufacturer (r'^/mohawk/$', 'django.views.generic.list_detail.object_list', mohawk_dict), (r'^/milliken/$', 'django.views.generic.list_detail.object_list', milliken_dict), (r'^/shaw/$', 'django.views.generic.list_detail.object_list', shaw_dict), (r'^/sphinx/$', 'django.views.generic.list_detail.object_list', sphinx_dict), This way seems like a waste. Would I need to create a unique dictionary for each manufacturer? Is there a way I can use the same dictionary for every manufacturer? Or does somebody have a better solution than what I came up with above? Thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---