[Answered ]-Given Arguments is less than Taken Arguments

2πŸ‘

βœ…

In views.py your type view takes exactly 3 arguments:

def type(request, type, page):
    ....

But in urls.py, you allow it to get only 2 arguments:

url(r'^gul/(\d+)$', 'site1.views.type'),

In this case, (\d+) will be taken as the 2nd argument for your view as type, since request is the default argument for every function based view.

What you should do is probably reduce the arguments in your view like:

def type(request, page):
    ...

And assign some name for your argument in urls.py:

url(r'^gul/(?P<page>\d+)$', 'site1.views.type'),

(?P<id>\d+) will match \d+ pattern and assign it to page.

If you still want to keep 3 arguments in your view, you should change the pattern of the URL:

url(r'^gul/(?P<type>\d+)/(?P<page>\d+)$', 'site1.views.type'),

So your URL should be something like /gul/2/1 and in you view, you will get type = 2 and page = 1.

Hope it helps.

πŸ‘€Hieu Nguyen

Leave a comment