Brm Azdn
Brm Azdn

Reputation: 13

NoReverseMatch: Reverse for '' not found. '' is not a valid view function or pattern name

Help me please!

Sorry about my english , i'm weak in english!

I am trying to visit this page 192.168.56.102 / project / BP / 4, it shows me this msg error! the same configurations of urls and views with other page it works fine.

Reverse for '' not found. '' is not a valid view function or pattern name.
Request Method: GET
Request URL:    http://192.168.56.102/project/BP/4
Django Version: 2.1.7
Exception Type: NoReverseMatch
Exception Value:    
Reverse for '' not found. '' is not a valid view function or pattern name.

urls.py :

urlpatterns = [
    #Project : 
    path('', views.projects , name = 'project'),
    path('BP/<int:id_project>', views.tb_project , name='tb_project'),
    path('add/', views.add_project , name = 'add_project'),
    path('delete/p/<int:id_project>',views.delete_project , name='delete_project'),
    path('edit/<int:id_project>' , views.edit_project , name = 'edit_project'),
    #Zone Action : 
    path('zone/<int:id_project>/' , views.list_zones , name ='list_zone'),
    path('zone/add/<int:id_project>/' , views.add_ZoneAction , name = 'add_zone'),
    path('delete/z/<int:id_project>/<int:id_zone>',views.delete_zone , name='delete_zone'),
    path('zone/edit/<int:id_zone>' , views.edit_ZoneAction , name = 'edit_zone'),
]

views.py :

def tb_project(request,id_project):
    template ="project/bord_project.html"
    context = {}
    prj = get_object_or_404(project ,id = id_project)
    context["prj"] = prj
    return render(request, template ,context)

page.html

<a href="{% url 'tb_project' element.id %}"> 
<!-- element.id = 4 -->

the link is displayed correctly in the page : 192.168.56.102/project/BP/4 but when I click to go to bord_project.html I see an error msg!

Page.html :
list_tuple is context variable

{% extends "base.html" %}
{% load static %}

{% block contenu %}

    <div class="container">

        {% for elements in list_tuple  %}

        <div class="row" style="margin-top : 10px;">

            {% for element in elements %}

            <div class = "col-4">
                <div class="card text-center">
                    <div class="card-header">
                        Projet
                    </div>
                    <div class="card-body">
                        <h5 class="card-title">

                            {{ element.intitule }}
                        </h5>
                        <p class="card-text">

                            {{ element.description|truncatewords:7 }}
                        </p>
                        <a href="{% url 'tb_project' element.id %}" class="btn btn-info">

                            {# link #}
                            Plus &raquo;
                        </a> 
                    </div>
                    <div class="card-footer text-muted">

                        {{ element.date }}
                    </div>
                </div>
            </div>

            {% endfor %}

        </div>

        {% endfor %}

    </div>  

for the moment bord_project.html is blank

{% extends "base.html" %}
{% load static %}

{% block contenu %}
  {# blank for the moment #}
{% endblock %}

Upvotes: 1

Views: 2184

Answers (1)

I do not believe the issue is in any code that you have pasted. You should run a $ grep -r -E "reverse|url" . or similar search command to find any url resolutions that you might be missing.

Somewhere you have a reverse[_lazy] function call or url templatetag that is performing a bad lookup.

Make sure that any uses of the url templatetag are using quotes around the view name.

Upvotes: 1

Related Questions