0

I have problem with passing an argument from url to my view.

url:

from ProjectName import settings
from django.conf.urls import url, include
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
import ProjectName.views as views
from register import views as registerViews
from profile import views as profileViews
from login import views as loginViews
from user import views as userViews
from django.contrib.flatpages import views as flatPageViews

urlpatterns = i18n_patterns(
                             url(r'^user/area/decline/(?P<id>\d+)/$', userViews.DeclineUser, name='decline_user'),
                             .
                             .
                           )

view:

@login_required
def DeclineUser(request, id):
    print("Here: " + id)

And I get the following error:

TypeError at /en/user/area/decline/48136796350054996/
DeclineUser() got an unexpected keyword argument 'id'

I search many related problems but all of them their function argument name didn't match the url argument, which in my case does!

Phrixus
  • 1,209
  • 2
  • 19
  • 36
  • What are the dots in your urlpatterns doing? – cezar Aug 10 '16 at 07:44
  • Is to use a minimal example code as the other URLs are not related to my question. I have also commented out all the other URLs and the problem is the same which means the problem is at the specific line I have listed. – Phrixus Aug 10 '16 at 07:45
  • Your url pattern 'decline_user' looks fine. The problem must be caused by some other code. Can you please also post the imports you're doing in urls.py? – cezar Aug 10 '16 at 07:51
  • @cezar I have updated my question – Phrixus Aug 10 '16 at 07:55
  • I found duplicate function name! That's the problem. I just removed the old one and now works. – Phrixus Aug 10 '16 at 07:56

0 Answers0