2011-07-09 14 views
5

त्रुटि:Django: पकड़ा NoReverseMatch जबकि प्रतिपादन: '*' तर्क के साथ '()' और कीवर्ड तर्क '{}' के लिए रिवर्स नहीं मिला

Caught NoReverseMatch while rendering: Reverse for 'archive' with arguments '()' and keyword arguments '{}' not found. 

Template error 

In template /home/bravedick/Aptana Studio 3 Workspace/blog/templates/homepage/index.html, error at line 7 

लाइन 7:

6 <a href="{% url index %}">Index</a> 
7 <a href="{% url archive %}">Archive</a> 
8 <a href="{% url contacts %}">Contacts</a> 

मुख्य urls.py:

from django.conf.urls.defaults import patterns, include, url 

# Uncomment the next two lines to enable the admin: 
from django.contrib import admin 
admin.autodiscover() 

urlpatterns = patterns('', 
    # Examples: 
    (r'^$', include('blog.apps.homepage.urls')), 
    # url(r'^$', 'blog.views.home', name='home'), 
    # url(r'^blog/', include('blog.foo.urls')), 

    # Uncomment the admin/doc line below to enable admin documentation: 
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), 

    # Uncomment the next line to enable the admin: 
    url(r'^admin/', include(admin.site.urls)), 
) 

मेरी urls.py:

from django.conf.urls.defaults import * 

urlpatterns = patterns('blog.apps.homepage.views', 
    url(r'^$', 'index', name='index'), 
    url(r'^about/$', 'about', name='about'), 
    url(r'^archive/$', 'archive', name='archive'), 
    url(r'^contacts/$', 'contacts', name='contacts'), 
) 

विचार:

from django.shortcuts import render_to_response 
from blog.apps.data.models import Entry 

def index(request): 
    entries = Entry.objects.published_entries().order_by('-id') 
    ctx = {'entries':entries} 
    return render_to_response("homepage/index.html", ctx) 

def about(request): 
    return render_to_response("homepage/about.html") 

def contacts(request): 
    return render_to_response("homepage/contacts.html") 

def archive(request): 
    return render_to_response("homepage/archive.html") 

उत्तर

9

मैं अपने मुख्य यूआरएल विन्यास के साथ एक तात्कालिक समस्या देख सकते हैं। आपके पास '$' प्रतीक है, जिसमें आपके शामिल कथन में यूआरएल के अंत का संकेत है।

कि लाइन पढ़ना चाहिए:

(r'^', include('blog.apps.homepage.urls')), 

यहाँ the documentation for include है।

यह भी जांचें कि blog.apps.homepage.urls एक वैध आयात पथ है।

./manage.py shell 

तो टाइप करें::

from blog.apps.homepage import urls 

आप एक आयात त्रुटि मिलती है, बाहर काम करने के क्या उचित आयात पथ होना चाहिए कोशिश करते हैं और उपयोग करें कि में अपने शामिल एक Django खोल खोलने के लिए निम्नलिखित भागो बयान।

+0

आप सही हैं। धन्यवाद। – bravedick

संबंधित मुद्दे