Reputation: 1219
I am trying to implement an approve and decline functionality of a profile using the following approach:
/user/area/decline/234322
/user/area/approve/234322
So I wrote the following URL pattern:
urlpatterns = i18n_patterns(
url(r'^user/area/decline/(?P<userid>\[0-9]+)/$', views.DeclineUser),
url(r'^user/area/approve/(?P<userid>\[0-9]+)/$', views.ApproveUser),
url(r'^user/area/$', views.Index),
.
.)
And my views:
@login_required
def DeclineUser(request, userid=""):
print("Here: " + userid)
@login_required
def ApproveUser(request, userid=""):
print("Here: " + userid)
But something is wrong and the methods are not triggered and the Index is triggered instead so I guess the problem is that the URL RegEx is not matching what I need.
Upvotes: 0
Views: 38
Reputation: 43300
Both of your url's have a \
in them so you are escaping the opening [
bracket, you just need to remove those slashes.
url(r'^user/area/decline/(?P<userid>[0-9]+)/$', views.DeclineUser),
url(r'^user/area/approve/(?P<userid>[0-9]+)/$', views.ApproveUser),
Upvotes: 1