ciao!
mi sto studiando django, ed ho un problema con la view.
in ricerche/views.py ho questo:
codice:
from django.shortcuts import get_object_or_404, render
from ricerche.models import Ricerche
def index(request):
rows = Ricerche.objects.all()
context = {'rows': rows}
return render(request, 'ricerche/index.html', context)
def detail(request, r_id):
ricerca = Ricerche.objects.get(pk=r_id)
return render(request, 'ricerche/detail.html', {'ricerca': ricerca})
in miosito/urls.py:
codice:
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.views.generic import RedirectView
urlpatterns = patterns('',
url(r'^$', RedirectView.as_view(url='/ricerche/')),
url(r'^ricerche/', include('ricerche.urls', namespace="ricerche")),
url(r'^admin/', include(admin.site.urls)),
)
poi di nuovo dentro ricerche/templates/ricerche/index.html:
codice:
{% if rows %}
<ul>
{% for r in rows %}
<li><a href="{% url 'ricerche:detail' r.id %}">{{ r.titolo }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}
ottengo questo errore:
codice:
NoReverseMatch at /ricerche/
Reverse for 'detail' with arguments '(1L,)' and keyword arguments '{}' not found. 0 pattern(s) tried: []
<li><a href="{% url 'ricerche:detail' r.id %}">{{ r.titolo }}</a></li>
qualcuno sa darmi una mano al riguardo??