我按照以下方式重新组织了Django:
I re-organized Django,the following way:
config - settings - base.py - local.py urls.py wsgi.py还应用:
- apps(level0) - acc(level_1) - users(level_2) - templates - users - acc_control(level_2) -att(level_1) - notes (level_2) - notifications (level_2) - mark(level_1) - config (level0) - templates(level0)某些应用程序直接位于apps文件夹中,例如,标记,其他应用程序位于其他子文件夹中,即用户
Some apps are directly in apps folder, ex mark, others are in other subfolders, ex users
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')]我的问题是ng模板访问权限,因为出现以下错误:
My issue is regarding templates access, because I receive the following error:
\apps\acc\users\templates\users\templates\users\detail.html (Source does not exist)重复内部文件夹;
在视图中,模板设置为:
template_name = 'users/templates/users/detail.html'我也尝试过:
template_name = '/users/detail.html'推荐答案
您不需要 users / templates / 设置 template_name 时的code>前缀。只要您在 TEMPLATES 设置中具有'APP_DIRS':True ,应用目录加载程序就会检查 templates 目录,包括 users / templates
You don't need the users/templates/ prefix when you set template_name. As long as you have 'APP_DIRS': True in your TEMPLATES setting, the app directories loader will check the templates directory for every installed app, including users/templates
template_name = 'users/detail.html'更多推荐
修改Django布局结构后访问Django模板
发布评论