2013-08-29 5 views
1

나는 내 블로그를 개발하고 있습니다. 모든 것이 좋았습니다. 나는 그것을 성공적으로 전개하지 못했습니다. 지금은 모든 변경 사항을 취소,하지만 지금은 작동하지라는 이름의 URL (그들은 완벽하게 이전에 일했다) : 오류 :django 1.5 및 python 2.7에서 url이 작동하지 않습니다.

Reverse for ''main_page'' with arguments '()' and keyword arguments '{}' not found 

URL :

urlpatterns = patterns('', 
    url(r'^$', main_page, name='main_page'), 
    url(r'^blog/', include('blog.blogurls')), 
    url(r'^comments/', include('django.contrib.comments.urls')), 
) 

메인 페이지 뷰 :

def main_page(request): 
    object_list = Article.objects.all() 
    return render_to_response('blog/main_page.html', {'Latest': object_list} 

을 에서 사용되는 명명 된 URL :

<p><a href="{% url 'main_page' %}">home</a></p> 

답변

0

{% url 'main_page' %}{% url main_page %}으로 바꿉니다. 장고 1.5 changelog에서

견적 :

One deprecated feature worth noting is the shift to “new-style” url tag. Prior to Django 1.3, syntax like {% url myview %} was interpreted incorrectly (Django considered "myview" to be a literal name of a view, not a template variable named myview). Django 1.3 and above introduced the {% load url from future %} syntax to bring in the corrected behavior where myview was seen as a variable.

The upshot of this is that if you are not using {% load url from future %} in your templates, you’ll need to change tags like {% url myview %} to {% url "myview" %}. If you were using {% load url from future %} you can simply remove that line under Django 1.5

+0

일했다. 템플릿의 변경 사항은 기억이 안납니다. 고맙습니다 – user2647448

+0

템플릿에'{% %부터로드 URL %}'이 있습니까? – alecxe

+0

아니요! 미래의 URL은 무엇입니까? – user2647448

관련 문제