一个 django 项目,下面有两个 app,这两个 app 会分别调用两个 html,但这个两个 html 名字相同。应该如何配置?

2015-11-23 20:08:06 +08:00
 chaleaoch
例如:

文件结构是这样的:
(django_18)chale@chale-pc:~/learning/mayday/mayday$ tree
.
(django_18)chale@chale-pc:~/learning/mayday/mayday$ tree
.
├── apptest
│   ├── admin.py
│   ├── __init__.py
│   ├── models.py
│   ├── templates
│   ├── tests.py
│   └── views.py
├── db.sqlite3
├── main
│   ├── admin.py
│   ├── __init__.py
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   └── __init__.py
│   ├── models.py
│   ├── templates
│   ├── tests.py
│   └── views.py
├── manage.py
└── mayday
├── __init__.py
├── settings.py
├── urls.py
└── wsgi.py



log 是这样的:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
/home/chale/.virtualenvs/django_18/local/lib/python2.7/site-packages/django/contrib/admin/templates/index.html (File does not exist)
/home/chale/.virtualenvs/django_18/local/lib/python2.7/site-packages/django/contrib/auth/templates/index.html (File does not exist)
/home/chale/learning/mayday/mayday/main/templates/index.html (File does not exist)
/home/chale/learning/mayday/mayday/apptest/templates/index.html (File does not exist)


本人菜鸟,大神轻喷。
4231 次点击
所在节点    Python
3 条回复
chaleaoch
2015-11-23 20:12:31 +08:00
如果按照 django 的默认配置,他会先找 main ,然后找 apptest 。
这并不是我想要的。

如果在 settings 里设置,它会先找 settings 里面的配置,这也不是我想要的。

虽然目前的项目中,还没有这个需求,但是这种情况是必然会出现的。当 app 复用的时候。。。
geeklian
2015-11-23 21:56:13 +08:00
templates\appname\xxxxx.html
只能这样咯
chaleaoch
2015-11-24 09:32:47 +08:00
@geeklian 昨天睡觉的时候想到了~谢谢大牛~

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/238339

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX