문제

나는 django 형태의 줄이 있습니다.

{% for aa in my_array %}

이 오류를 유발하는 것 같습니다.

템플릿 오류

렌더링하는 동안 예외를 발견했습니다.

이 오류 메시지는 실제로 무엇을 의미합니까?

줄이 정확하다고 생각하지만 오류 메시지가 잘못되었습니다. 또는 오류는 실제이지만이 줄은 붉은 색입니다.

지구상에서 무엇을 찾고 있습니까?

업데이트 : Paulo는 아래를 정리했습니다.

사실, 나는 a {% url viewPlan planId %} 두 줄 (보고 된 오류 줄이 잘못되었습니다)이지만이 경우 PlanID가 비어 있었기 때문에 오류가 트리거되었습니다.

도움이 되었습니까?

해결책

Do you have a view named viewPlan with which you do something like this in a template:

{% url viewPlan %}

or something like this in a view:

reverse('viewPlan')

If you do that and you do not have a line that looks like this:

url(r'^whatever/url/$', 'dev_env.profiles.views.viewPlan', name="viewPlan"),

...in your url configuration I would imagine that's the error you're getting. Alternatively, and more likely, you are probably capturing a value (maybe id or something) in the viewPlan URL but are not passing an argument when reversing the url. So if you are capturing any values in the regex, like this:

url(r'^plans/(\d+)$', 'dev_env.profiles.views.viewPlan', name="viewPlan"),

You need to call it like this:

{% url viewPlan 15 %}

Or like this:

reverse('viewPlan', args=[15]);

Where 15 is obviously whatever the captured value is expecting.

다른 팁

I had the same issue. In my case, I'd forgotten to add the urls for the child app in the main urls.py file:

urlpatterns = [
    re_path("admin/", admin.site.urls),
    re_path(r"^core/", include("core.urls")),
    re_path(r"^$", welcome, name="welcome")
]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top