I try to use an updateview with a form. I get the error:
Reverse for 'response' with arguments '('',)' not found. 1 pattern(s)
tried: ['app/response/(?P<pk>[-a-zA-Z0-9_]+)/$']
views.py:
class ResponseUpdateView(UpdateView):
model = Model
fields = ['response']
urls.py
path( route='response/<slug:pk>/', view=views.ResponseUpdateView.as_view(), name='response' )
template:
{% extends "base.html" %}
{% load crispy_forms_tags %}
{% block title %}{% endblock %}
{% block content %}
<form method="post" action="{% url 'tower:response' slug %}">
{% csrf_token %}
{{ form|crispy }}
<button type="submit" class="btn btn-primary">Send</button> </form>
{% endblock %}
the error is in the template {% url 'app:response' pk %} specifically pk, I have tried using:
def get_context_data(self, **kwargs):
context = super(ResponseUpdateView, self).get_context_data(**kwargs)
context['slug'] = self.kwargs['pk']
together with {% url 'app:response' slug %}
If I don't add the url everything works fine
question from:
https://stackoverflow.com/questions/65882205/noreversematch-at-updateview 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…