Article From:

python 3.6,django 2.0.4URL matching errors when developing a web site,
I hope to help me point out the mistakes.
NoReverseMatch at /CetTopic/

Reverse for ‘personal_info’ with arguments ‘(”,)’ not found. 1 pattern(s) tried: [‘CetPersInfo/(?P<topic_id>\d+)$’]


from django.conf.urls import url
from django.urls import path
from cet46.views import personal_info
from . import views


urlpatterns = [
    url(r'^CetPersInfo/(?P<topic_id>\d+)$',views.personal_info,name='personal_info'),#It's a problem in this regular expression.]

viewsThe view function inside:

def personal_info(request,topic_id):
    topic = Topic.objects.get(id=topic_id)
    perInfo = topic.objects.all()
    context = {'perInfo': perInfo}
    return render(request, 'cet46/perInfo.html', context)

Template HTML file:

{% extends "cet46/base.html" %}
<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <table width="500">
                <th>ID</th> <th>Name < /th> < th> ID card number < /th> < th> sex < /th> < < age;< th> mobile phone number < /th> < th> school < /th> < th> address < th>< /tr>< /thead>< tbody>{% for row in perInfo%}< tR>< td>}}< /td>< td> (row.username))< /td>< td> row.user_id}}< /td>< td> (row.)Gender}}< /td>< td> row.age}}< /td>< td>}}< /td>< td>}}< /td>< tD> (row.addr}}< /td>< /tr>{% endfor%}< /tbody&gT;< /table>< /div>< /body>< /html>

There is an error when the home page hits Apply CET.

Backstage error:

Answer 0:

Yes, your URL configuration is out of order. Try this.
from django.urls import re_path
re_path(‘CetPersInfo/(?P<topic_id>d+)/’,views.personal_info,name=’personal_info’),In fact, more than Django2.0 versions are in this format.

Similar Posts:

One Reply to “Django error: Reverse for ” with arguments’ (‘,’), not found.”

Leave a Reply

Your email address will not be published. Required fields are marked *