Hi Robert,

In those cases a HTTP 404 is the right response, to help Search Engines realise 
that such a URL doesn’t exist and to show users a "Page Not Found" message. To 
create a nice looking 404 response for users just write a view to handle it and 
add the “handler404” entry to your root URLConf module (the one near the 
settings.py module).

Adding something like this to urls.py:

handler404 = ‘views.http404_handler’

And creating that view in the corresponding views.py module:

from django.http import HttpResponseNotFound
from django.template import loader, RequestContext

def http404_handler(request):
    t = loader.get_template("404.html")
    return HttpResponseNotFound(
        t.render(RequestContext(request, {'request_path': request.path})))

Also create the template 404.html in your templates directory.

Read more on the topic here: 
https://docs.djangoproject.com/en/1.7/ref/views/#the-404-page-not-found-view

Good luck,
Daniel


On 23 Sep 2014, at 04:25, robert brook <software.by.pyt...@gmail.com> wrote:

> How is a url conf written so that if none of the useful urls are matched it 
> will pass through to some sort of wild card regular expressions so that the 
> view / redirection can be performed gracefully
> 
> Thanks
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/f981954c-679a-4000-9e4c-11d3e6ee3e09%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to