Django view got an unexpected keyword argument

django, python-2.7

Solution

Try this:

Your `urls.py`:-

urlpatterns = pattern('whatever_your_app.views',
    ...
    url(r'edit-offer/(?P<id>\d+)/$', 'edit_offer', name='edit_offer'),
)

Your `views.py`:-

from django.contrib.auth.decorators import login_required

...

@login_required
def edit_offer(request, id):
    # do stuff here

and in your `template`:-

{% url 'edit_offer' offer.id %}

Problem

I have a following url pattern: ``` urlpatterns = pattern('', ... url(r'edit-offer/(?P<id>\d+)/$', login_required(edit_offer), name='edit_offer'), ) ``` and a corresponding edit_offer view: ``` def edit_offer(request, id): # do stuff here ``` a link on offer page leads to edit offer view: ``` <a class="btn" href="{% url edit_offer offer.id %}">Edit</a> ``` clicking on the button throws a TypeError: ``` edit_offer() got an unexpected keyword argument 'offer_id' ``` Any ideas what is going on? I don't see what's wrong here. I have other views with similar patterns and they all work ok.

Original source