On Mon, 7 Apr 2008, ichbindev wrote:
> that would take care of (b) where no page was matched. It would also > take care of (a) but in principle the home page should not be reached > through a "page not found" kind of thing. I agree, in your initial post you said: > Both of these are not handled by the sample urlconf. However, in both > situations, I would like the user to be redirected to a default page, > which would be the home or index page. and I overlooked the "redirected" part. So, are you wanting to display the home page if just the host name is entered and redirect to the home page, so that the url in the user's browser gets changed to just the site's host name, if a non-existent url is entered? > (1) What pattern should be used to handle case (a) where we are > matching for the home page (i.e. just the URL and nothing after that)? > (2) How is handler404 configured in urlconf? Could you provide a > sample urlconf file which would implement handler404 with a custom > redirection? I hadn't actually tried it myself. I'm a newbie and found the info by Googling for Django 404. To test I just modified my urlconf file to achieve what I think you're looking for. It now looks like: from django.conf.urls.defaults import * from django.views.generic.simple import direct_to_template handler404 = 'WAG.wag.views.to_home_page' urlpatterns = patterns('', ('^$', 'WAG.wag.views.index'), (r'^Agility/(?P<page>.*)$', 'WAG.agility.views.index'), etc., etc.) And, the to_home_page function, and needed imports, in the view looks like: from django.http import HttpResponseRedirect from django.core.urlresolvers import reverse def to_home_page(request): return HttpResponseRedirect(reverse('WAG.wag.views.index')) Kevin http://www.RawFedDogs.net http://www.WacoAgilityGroup.org Bruceville, TX Si hoc legere scis nimium eruditionis habes. Longum iter est per praecepta, breve et efficax per exempla!!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---