2017-12-13 8 views
0

의 템플릿 폴더에 액세스하고, 그와 같은 구조로 프로젝트 "처음 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 사용 I 앱/템플릿/응용 프로그램/모든 HTML 파일에 액세스 할 수 있습니다

.......... 

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', 



      ], 
     }, 
    }, 
] 

내 문제 : 응용 프로그램 settins.py와 이름을 "응용 프로그램"는 내용이있다. 하지만 app/templates/app/report에 하나의 폴더를 보고서로 만들면 report/audiance_overview.html에 액세스 할 수 없습니다.

내가 액세스하도록 도와주세요.

덕분에, Jame

+0

"액세스 할 수 없다"는 것은 무엇을 의미합니까? 어떤 방법으로 파일에 액세스하려고합니까? 템플릿에서? url.py? 보기에서? – nakiya

+0

localhost : 8000/index.html에서 액세스 할 수 없지만 localhost : 8000/report/audiance_overview.html에 액세스 할 수 없습니다. –

+0

여기에 'urls.py'붙여 넣기 파일을 복사 할 수 있습니까? – nakiya

답변

0

당신은 다른 두 가지가 (당신이 예를 들면 PHP는 세계에서 오는 경우,이 같은 행동이 아니다) 장고에 혼란 파일 경로 및 URL을 것 같다. django 개발 서버를 사용하는 경우에는 그런 방법으로 템플릿에 액세스 할 수 없습니다.

간단히 말해, views.py의보기를 가리키는 URL을 urls.py에 정의해야합니다.이 URL은 템플릿을 호출합니다. 이것이 어떻게 작동하는지에 대한 자세한 예는 https://docs.djangoproject.com/en/1.11/intro/tutorial03/을 참조하십시오.

처음에는 무거워 보일 수 있지만, 파일 시스템 제약 조건에서 벗어나기 때문에 URL 체계를 훨씬 잘 제어 할 수 있습니다.