2012-07-11 73 views
0

错误

Caught NoReverseMatch while rendering: Reverse for ''tazasabzii.tazasabzi.views.gallery'' with arguments '()' and keyword arguments '{}' not found. 

urls.py

urlpatterns = patterns('tazasabzii.tazasabzi', 

    (r'^tazasabzi/gallery/$', 'views.gallery'), 

views.py

def gallery(request): 
    z = {'title':'TazaSabzi.com', 
     'heading':'TazaSabzi.com', 
     'viewName':'gallery',} 
    fruits = Sabji.objects.filter(kind__contains="fruit") 
    sfruits = Sabji.objects.filter(kind__contains="special fruit") 
    svegetables = Sabji.objects.filter(kind__contains="special vegetable") 
    vegetables = Sabji.objects.filter(kind__contains="vegetable") 
    soffers = Sabji.objects.filter(kind__contains="special offer") 
    saari_sabzi = {'fruits':fruits, 
              'vegetables':vegetables, 
              'special fruits':sfruits, 
              'special vegetables':svegetables, 
              'special offers':soffers,} 
    return render_to_response('gallery.html',{'tz':z, 
               'saari_sabzi':saari_sabzi.iteritems(),},context_instance=RequestContext(request)) 

错误

154  <a target="_blank" href="{% url 'tazasabzii.tazasabzi.views.gallery' %}"> 
155  <div class="gallery button" style="width:100px;"> 
156  <div style="color:white; margin-top:5px;">Gallery</label> 

回答

0

尝试类似<a target="_blank" href="{% url 'appname.views.gallery' %}">

OR

使用named URLs

OR

可能是你没有包含的应用程序网址在主url_conf

+0

仍然会生成相同的错误 – Abhimanyu 2012-07-11 16:47:56

+1

阅读文档的['url tag']](https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#url)。 – machaku 2012-07-11 17:33:36

+0

是的,我已经尝试了所有可能的组合,它根本不工作,一次又一次的错误 – Abhimanyu 2012-07-11 18:51:52