0

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.

2
  • Any errors? What does happen? Commented Aug 10, 2016 at 6:59
  • As I said the method is not triggered and the closer match is triggered instead which is user/area Commented Aug 10, 2016 at 7:02

1 Answer 1

1

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),
Sign up to request clarification or add additional context in comments.

3 Comments

Correct but this didn't fixed the problem. The /user/area is triggered instead.
Well now I get the following error: DeclineUser got an unexpected keyword argument 'userid'
@John - Thats a different issue to do with your view, the views you've shown have different names

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.