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.
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 %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With