【发布时间】:2018-05-26 20:45:10
【问题描述】:
我是 Django 的新手,我创建了一个项目“第一个 pycharm”,其结构如下:
\firstpycharm
| manage.py
| views.py
+---firstpycharm
| | middleware.py
| | models.py
| | settings.py
| | urls.py
| | wsgi.py
| | __init__.py
| |
| +---__pycache__
+---app
| | models.py
| | models.pyc
| | urls.py
| | views.py
| +---migrations
| +---static
| | +---build
| | +---images
| | +---vendors
| +---templates
| | **\---app
| | | base_site.html
| | | base_site_bk.html
| | | index.html
| | | index2.html
| | | index3.html
| | | index_bk.html
| | | invoice.html
| | | level2.html
| | | login.html
| | | map.html
| | | media_gallery.html
| | | morisjs.html
| | | other_charts.html
| | | page_403.html
| | | page_404.html
| | | page_500.html
| | | plain_page.html
| | | pricing_tables.html
| | | profile.html
| | | projects.html
| | | project_detail.html
| | | sidebar.html
| | | tables.html
| | | tables_dynamic.html
| | | top_navigation.html
| | | typography.html
| | | widgets.html
| | | xx.html
| | \---report
| | audiance_overview.html**
+---static
| \---script
+---staticfiles
| \---admin
| +---css
| +---fonts
| +---img
| | \---gis
| \---js
| +---admin
| \---vendor
| +---jquery
| \---xregexp
+---templates
我的第一个 pycharm 使用一个名为“app”的应用程序,settins.py 有内容:
..........
INSTALLED_APPS = [
'django_cassandra_engine',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'app',
'firstpycharm',
]
..........
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
我的问题是我可以访问 app/templates/app/ 中的所有 html 文件。但是当我在 app/templates/app/report 中创建 1 个文件夹作为报告时,我无法访问 report/audiance_overview.html。
请帮我访问它们。
谢谢, 詹姆斯
【问题讨论】:
-
“无法访问”是什么意思。您尝试以哪种方式访问文件?在模板中?在 url.py 中?在视图中?
-
我无法通过 localhost:8000/index.html 访问但无法访问 localhost:8000/report/audiance_overview.html
-
你能在这里复制粘贴
urls.py吗? -
我是
app/report/audiance_overview.html -
@Ykh 请编辑问题并在此处发布
urls.py的内容。谢谢。
标签: python django django-templates django-apps