python - Django - Exception Type: NoReverseMatch -


hi guys im learning django im getting error , dont know how fix it, can me please? python 3.x / django 1.9

im getting error:

noreversematch @ / reverse 'categoria' arguments '(1,)' , keyword arguments '{}' not found. 0 pattern(s) tried: [] request method: request url:    http://127.0.0.1:8000/ django version: 1.9.1 exception type: noreversematch exception value:     reverse 'categoria' arguments '(1,)' , keyword arguments '{}' not found. 0 pattern(s) tried: [] exception location: c:\users\yiyeh\appdata\local\programs\python\python35-32\lib\site-packages\django\core\urlresolvers.py in _reverse_with_prefix, line 508 python executable:  c:\users\yiyeh\appdata\local\programs\python\python35-32\python.exe python version: 3.5.1 python path:     ['c:\\users\\yiyeh\\documents\\ejercicios\\python\\puls\\puls',  'c:\\users\\yiyeh\\appdata\\local\\programs\\python\\python35-32\\python35.zip',  'c:\\users\\yiyeh\\appdata\\local\\programs\\python\\python35-32\\dlls',  'c:\\users\\yiyeh\\appdata\\local\\programs\\python\\python35-32\\lib',  'c:\\users\\yiyeh\\appdata\\local\\programs\\python\\python35-32',  'c:\\users\\yiyeh\\appdata\\local\\programs\\python\\python35-32\\lib\\site-packages'] server time:    wed, 27 jan 2016 17:52:56 -0300  django.shortcuts import render_to_response django.http import httpresponse django.template.loader import get_template django.template import context datetime import datetime app.models import * 

this view.py

def home(request):     categorias = categoria.objects.all()     enlaces = enlace.objects.all()     template = "index.html"     #diccionario = {"categorias": categorias,"enlaces":enlaces}     return render_to_response(template,locals()) 

urls.py

from django.conf.urls import url django.contrib import admin  urlpatterns = [     url(r'^admin/', admin.site.urls),     url(r'^$', 'app.views.home', name='home'), ] 

and index.html ( error on line 30 )

<!doctype html> <html lang="es"> <head>     <meta charset="utf-8" />      <meta name="viewport"            content="width=device-width, initial-scale=1, maximum-scale=1" />      <title>puls3: comunidad online de gente pro y (no sé que más escribir)</title>     <link rel="stylesheet" href="normalize.css" />     <link href='http://fonts.googleapis.com/css?family=pt+sans:400,700,400italic,700italic' rel='stylesheet' type='text/css' />     <link rel="stylesheet" href="/static/estilos.css" />     <link rel="stylesheet" href="/static/responsive.css" /> </head> <body>     <!-- comentario de lo que sea -->     <header>         <figure id="logo">             <img src="logo.png" />         </figure>         <h1 id="titulo_header">puls3: comunidad de gente cool, atractiva y millonaria</h1>         <figure id="avatar">             <img src="avatar.jpg" />             <figcaption></figcaption>         </figure>     </header>     <nav>         <ul>             <li id="flechita_nav"><a href="/"></a></li>             {% cat in categorias %}                 <li><a href="{% url "categoria" cat.pk %}">{{cat}}</a></li>             {% endfor %}             <li id="publicar_nav"><a href="{% url "add" %}">publicar</a></li>         </ul>     </nav>     <aside id="bienvenida">         {% if not request.user.is_authenticated %}         <h2>hola, registrate!</h2>         <p>es importante registrarte porque lol!</p>         <a id="registro" href="#">registrate acá</a>         <p id="mensaje_registro">en serio, registrate por favor</p>         {% endif %}     </aside>     <section id="contenido">         {% if enlaces %}          {% enlace in enlaces %}         <article class="item">             <figure class="imagen_item">                 <img src="imagen.jpg" />             </figure>             <h2 class="titulo_item">                 <a href="{{enlace.enlace}}">{{enlace.titulo}}</a>             </h2>             <p class="autor_item">                 por <a href="#">{{enlace.usuario}}</a>             </p>             <p class="datos_item">                 <a class="tag_item" href="#">{{enlace.categoria}}</a>                 <span class="fecha_item">hace <strong>{{enlace.timestamp|timesince}}</strong> min</span>                 <a class="guardar_item" href="#"></a>             </p>             <p class="votacion">                 <a class="up" href="{% url "plus" enlace.pk %}"></a>                 {{enlace.votos}}                 <a class="down" href="{% url "minus" enlace.pk %}"></a>             </p>         </article>         {% endfor %}         {% else %}             no hay enlaces guardados         {% endif %}     </section>     <footer>         <p><strong>powered platzi!</strong></p>         <p>mejorando.la 2013 ®</p>     </footer> </body> </html> 

your problem template trying create hyperlinks don't have corresponding entries in urls.py file. whenever creating link (e.g., href="{% url 'categoria' cat.pk %}" django urls.py url name categoria takes 1 parameter - in case primary key. working, have have entry looking this:

urlpatterns = [     # other url entries...     url(r'^categoria/([0-9]+)/$', views.categoria_view, name='categoria'), ] 

the name argument used when reversing url. more in documentation here

note have create entries names using in {% url %} tags (e.g., categoria, plus, minus, add).


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -