How to capture any incorrect typing of a url and pass it to a default page

25 views
Skip to first unread message

pythonista

unread,
Dec 24, 2014, 11:15:26 AM12/24/14
to django...@googlegroups.com
I want to code the urls.py such that if someone types in any garbage inn the browser the final line of the url router will grab the line and reroute it to some page(the home page) for example.

I added the following line of code to the bottom of the url  

url(r'^([a-zA-Z0-9\-\_]*)', views.my_default),   expecting that it would send it to my default view

So, it appears to be working and  not matching anything above that  url and falls all the way through, however I am getting any error

TypeError at /waitlist/dict

my_default() takes exactly 1 argument (2 given)


My view is very simple

def my_default_2(request):
    context = RequestContext(request)
    context_dict = {'boldmessage': "pass through from waitlist"}
    return render_to_response('waitlist/home.html', context_dict, context)


So, it looks like it is getting to the view, but I am getting the error above.
Any suggestions as to why I am getting the argument error above.

Thanks


Vijay Khemlani

unread,
Dec 24, 2014, 11:23:45 AM12/24/14
to django...@googlegroups.com
Try adding the *args and **kwargs parameters

    def my_default_2(request, *args, **kwargs):
        ...

--
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...@googlegroups.com.
To post to this group, send email to django...@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/67d57b9e-6d36-4c17-aee0-1fef5db37d79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages