NoReverseMatch for easy viewing of Django

I get a NoReverseMatch error:

NoReverseMatch at /verfahrensverzeichnis/verzeichnis/320/

Reverse for 'verfahrenvorlage' with arguments '(320,)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['verfahrensverzeichnis/verfahren/vorlage/(?P<pk>[\\d+])/add/$']

For a fairly simple presentation, and I cannot understand what is wrong here. could you help me?

url.py:

url(r'^verfahren/vorlage/(?P<pk>[\d+])/add/$',
    views.verfahrenvorlage,
    name='verfahrenvorlage',
    ),

view.py:

def verfahrenvorlage(request, pk):

vorlagen = ProcedurTemplate.objects.all()
kunde_pk = pk

return render(request, 'verfahrensverzeichnis/vorlagen_auswahl.html', {'vorlagen': vorlagen, 'kunden_pk': kunde_pk})

from the .py template:

                <tr>
                    <td>
                        <a href="{% url 'verfahrensverzeichnis:verfahrenvorlage' verfahrensverzeichnis.customer.pk %}">Verfahren hinzufügen</a>
                    </td>
                </tr>
+4
source share
1 answer

The problem is in your regex:

(?P<pk>[\d+])

The inclusion +in square brackets means that you correspond to the sign “one digit or plus” instead of “more than one digit”.

It should be

(?P<pk>[\d]+)

Or, in this case, you can drop the square brackets.

(?P<pk>\d+)
+5
source

Source: https://habr.com/ru/post/1620329/


All Articles