There is urls.py,

urlpatterns = [ ..., url(r'^reviews/', views.reviews), url(r'^reviews/page(?P<page>\d+)/$', views.reviews), ] 

And there is view.py

 def reviews(request, page): ... 

Apache for some reason gives an error:

 reviews() missing 1 required positional argument: 'page', 

but the argument is present in view.py.

If in url.py change

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

on

 url(r'^reviews/page(?P<page_1>\d+)/$', views.reviews), 

and restart apache, the error will be the same, although it seems to me that it should already show such an error

 reviews() missing 1 required positional argument: 'page_1' 

If you add a default value in view.py

 def reviews(request, page=1): ... 

That, the error disappears, but regardless of the url, the page will always be equal to the default value.

Can anyone explain what is happening? django 1.9, apache 2.4.

  • 2
    Change r '^ reviews /' to r '^ reviews / $'? Regulars greedy and the second line will never be processed - all these requests will be considered for the first regular session. - m9_psy
  • Yes, it helped, thanks. How was it possible to forget about the end of the line. - OuroborosSK

1 answer 1

try this:

 def reviews(request, page=None): if page: ...