장고 2.0
include에 app_name 형태를 쓰지말고
urls.py 파일 내에 변수 app_name을 정의하면 그것이 namespace 역할을 하게 된다.
Inside myapp/urls.py add the following module-level attribute:
app_name = "polls"
This will set the "application namespace name" for that application. When you use names like "polls:submit" in a reverse, Django will look in two places: application namespaces (set like above), and instance namespaces (set using the namespace= parameter in the "url" function). The latter is important if you have multiple instances of an app for your project, but generally it's the former you want.
I had this very issue, and setting namespace= into the url() function seemed wrong somehow.
See this entry of the tutorial: https://docs.djangoproject.com/en/1.9/intro/tutorial03/#namespacing-url-names
Update: this information is correct for Django 1.9. Prior to 1.9, adding a namespace= attribute to the include is, indeed, the proper way.
'Python' 카테고리의 다른 글
git pull 시 문제해결 (654) | 2018.01.28 |
---|---|
장고 프레임워크 - 모델 표기가 안될 때 __unicode__ (664) | 2018.01.27 |