2016-12-15 5 views
0

enter image description here장고 1.10 주장 템플릿이 존재하지 않지만, 분명히

을 수행하지만 복사 파이어 폭스에 해당 위치에 붙여 넣을 경우, 템플릿이있다 :

def artists(request): 
    artists = Artist.objects.all() 
    template = loader.get_template('artists/index.html') 
    context = {'artists': artists,} 
    return HttpResponse(template.render(context, request)) 

index.html을 :

{% extends "site_base.html" %} 

{% load i18n %} 

{% block head_title %}pinax-project-account{% endblock %} 

{% block body_class %}home{% endblock %} 

{% block body_base %} 
    <section class="jumbotron"> 
     <div class="container"> 
      {% include "_messages.html" %} 
      <h1>{% blocktrans %}Welcome to<br>pinax-project-account{% endblocktrans %}</h1> 
      <p> 
       {% blocktrans %} 
       In addition to what is provided by the "zero" project, this project 
       provides thorough integration with django-user-accounts, adding 
       comprehensive account management functionality. It is a foundation 
       suitable for most sites that have user accounts. 
       {% endblocktrans %} 
      </p> 
      {% if not user.is_authenticated %} 
      {% url "account_login" as login_url %} 
      {% url "account_signup" as signup_url %} 
      <p>{% blocktrans %}You can <a href="{{ login_url }}" class="btn btn-default">Log In</a> or <a href="{{ signup_url }}" class="btn btn-primary">Sign Up</a> to try out the site.{% endblocktrans %}</p> 
      {% endif %} 
     </div> 
    </section> 
    <section> 
     <div class="container"> 
      <h2 class="text-center">{% blocktrans %}What is Pinax?{% endblocktrans %}</h2> 
      <p class="lead"> 
       {% blocktrans %} 
       <b>Pinax</b> is an open-source platform based on Django and 
       intended to provide a starting point for websites. It takes 
       care of the things that many sites have in common, so you can 
       focus on what makes your site different. 
       {% endblocktrans %} 
      </p> 
      <div class="feature-columns"> 
       <div> 
        <i class="fa fa-cubes fa-3x"></i><br> 
        {% blocktrans %} 
        <b>Starter projects</b> provide project layout, 
        scaffolding, already integrated components and 
        ready-to-go code. 
        {% endblocktrans %} 
       </div> 
       <div> 
        <i class="fa fa-puzzle-piece fa-3x"></i><br> 
        {% blocktrans %} 
        <b>Reusable apps</b> provide common 
        infrastructure, back-end functionality, 
        and user-facing components. 
        {% endblocktrans %} 
       </div> 
       <div> 
        <i class="fa fa-tint fa-3x"></i><br> 
        {% blocktrans %} 
        <b>Themes</b> provide default templates and 
        stylesheets for quick prototyping and easy customization. 
        {% endblocktrans %} 
       </div> 
      </div> 
     </div> 
    </section> 
    <section> 
     <div class="container"> 
      <p class="lead text-center"> 
       {% blocktrans %} 
       See <a href="http://pinaxproject.com/">pinaxproject.com</a> 
       for more information. 
       {% endblocktrans %} 
      </p> 
     </div> 
    </section> 
{% endblock %} 

Settings.py : 사소한 솔루션을해야하는지에

import os 


PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) 
PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__)) 
BASE_DIR = PACKAGE_ROOT 

DEBUG = True 

DATABASES = { 
    "default": { 
     "ENGINE": "django.db.backends.sqlite3", 
     "NAME": "dev.db", 
    } 
} 

ALLOWED_HOSTS = [ 
    "localhost", 
] 

# Local time zone for this installation. Choices can be found here: 
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 
# although not all choices may be available on all operating systems. 
# On Unix systems, a value of None will cause Django to use the same 
# timezone as the operating system. 
# If running in a Windows environment this must be set to the same as your 
# system time zone. 
TIME_ZONE = "UTC" 

# Language code for this installation. All choices can be found here: 
# http://www.i18nguy.com/unicode/language-identifiers.html 
LANGUAGE_CODE = "en-us" 

SITE_ID = int(os.environ.get("SITE_ID", 1)) 

# If you set this to False, Django will make some optimizations so as not 
# to load the internationalization machinery. 
USE_I18N = True 

# If you set this to False, Django will not format dates, numbers and 
# calendars according to the current locale. 
USE_L10N = True 

# If you set this to False, Django will not use timezone-aware datetimes. 
USE_TZ = True 

# Absolute filesystem path to the directory that will hold user-uploaded files. 
# Example: "/home/media/media.lawrence.com/media/" 
MEDIA_ROOT = os.path.join(PACKAGE_ROOT, "site_media", "media") 

# URL that handles the media served from MEDIA_ROOT. Make sure to use a 
# trailing slash. 
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/" 
MEDIA_URL = "/site_media/media/" 

# Absolute path to the directory static files should be collected to. 
# Don"t put anything in this directory yourself; store your static files 
# in apps" "static/" subdirectories and in STATICFILES_DIRS. 
# Example: "/home/media/media.lawrence.com/static/" 
STATIC_ROOT = os.path.join(PACKAGE_ROOT, "site_media", "static") 

# URL prefix for static files. 
# Example: "http://media.lawrence.com/static/" 
STATIC_URL = "/site_media/static/" 

# Additional locations of static files 
STATICFILES_DIRS = [ 
    os.path.join(PROJECT_ROOT, "static", "dist"), 
] 

STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage" 

# List of finder classes that know how to find static files in 
# various locations. 
STATICFILES_FINDERS = [ 
    "django.contrib.staticfiles.finders.FileSystemFinder", 
    "django.contrib.staticfiles.finders.AppDirectoriesFinder", 
] 

# Make this unique, and don't share it with anybody. 
SECRET_KEY = "#t_)=9g2nssm4!6rw^vq(1_sqbnxi4zky--b8!crlvp(f1r=ol" 

TEMPLATES = [ 
    { 
     "BACKEND": "django.template.backends.django.DjangoTemplates", 
     "DIRS": [ 
      os.path.join(PACKAGE_ROOT, "templates"), 
      os.path.join(BASE_DIR, 'templates/'), 
      '/home/shawn/Workspace/WebSites/artCollective/ac3/ac3/templates/ac3/', 
     ], 
     "APP_DIRS": True, 
     "OPTIONS": { 
      "debug": DEBUG, 
      "context_processors": [ 
       "django.contrib.auth.context_processors.auth", 
       "django.template.context_processors.debug", 
       "django.template.context_processors.i18n", 
       "django.template.context_processors.media", 
       "django.template.context_processors.static", 
       "django.template.context_processors.tz", 
       "django.template.context_processors.request", 
       "django.contrib.messages.context_processors.messages", 
       "account.context_processors.account", 
       "pinax_theme_bootstrap.context_processors.theme", 
      ], 
     }, 
    }, 
] 

MIDDLEWARE = [ 
    "django.contrib.sessions.middleware.SessionMiddleware", 
    "django.middleware.common.CommonMiddleware", 
    "django.middleware.csrf.CsrfViewMiddleware", 
    "django.contrib.auth.middleware.AuthenticationMiddleware", 
    "django.contrib.auth.middleware.SessionAuthenticationMiddleware", 
    "django.contrib.messages.middleware.MessageMiddleware", 
    "django.middleware.clickjacking.XFrameOptionsMiddleware", 
] 

ROOT_URLCONF = "ac3.urls" 

# Python dotted path to the WSGI application used by Django's runserver. 
WSGI_APPLICATION = "ac3.wsgi.application" 

INSTALLED_APPS = [ 
    "django.contrib.admin", 
    "django.contrib.auth", 
    "django.contrib.contenttypes", 
    "django.contrib.messages", 
    "django.contrib.sessions", 
    "django.contrib.sites", 
    "django.contrib.staticfiles", 

    # theme 
    "bootstrapform", 
    "pinax_theme_bootstrap", 

    # external 
    "avatar", 
    "account", 
    "pinax.eventlog", 
    "pinax.webanalytics", 

    # project 
    "ac3", 
    "artists", 
] 

# A sample logging configuration. The only tangible logging 
# performed by this configuration is to send an email to 
# the site admins on every HTTP 500 error when DEBUG=False. 
# See http://docs.djangoproject.com/en/dev/topics/logging for 
# more details on how to customize your logging configuration. 
LOGGING = { 
    "version": 1, 
    "disable_existing_loggers": False, 
    "filters": { 
     "require_debug_false": { 
      "()": "django.utils.log.RequireDebugFalse" 
     } 
    }, 
    "handlers": { 
     "mail_admins": { 
      "level": "ERROR", 
      "filters": ["require_debug_false"], 
      "class": "django.utils.log.AdminEmailHandler" 
     } 
    }, 
    "loggers": { 
     "django.request": { 
      "handlers": ["mail_admins"], 
      "level": "ERROR", 
      "propagate": True, 
     }, 
    } 
} 

FIXTURE_DIRS = [ 
    os.path.join(PROJECT_ROOT, "fixtures"), 
] 

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" 

ACCOUNT_OPEN_SIGNUP = True 
ACCOUNT_EMAIL_UNIQUE = True 
ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = False 
ACCOUNT_LOGIN_REDIRECT_URL = "home" 
ACCOUNT_LOGOUT_REDIRECT_URL = "home" 
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 2 
ACCOUNT_USE_AUTH_AUTHENTICATE = True 

AUTHENTICATION_BACKENDS = [ 
    "account.auth_backends.UsernameAuthenticationBackend", 
] 
I have 

시간을 보냈다. 장고는 템플릿의 올바른 위치를 찾고 있는데, 왜 렌더링되지 않을 수 있습니까?

+0

당신은 setting.py에서 템플릿 폴더를 사용자 정의 했습니까? –

+0

네'settings.py' 코드를 보여줄 수 있습니까? –

+0

html을로드하는 것처럼 브라우저에서 템플릿을 여는 중입니다. 그건 장고 서버에서로드해야합니다 – karthikr

답변

1

봅니다 저도 같은 문제가 발생

os.path.join(BASE_DIR, 'templates') 
0

에 settings.py에서 templates 후 슬래시를 제거하고 마침내 그것을 해결합니다. 메모장에 html 파일을 만든 경우;

  • 메모장 파일에있는 내용을 복사하여 워드 패드 파일에 붙여 넣으십시오.

  • 은 저장 ... 다음 줄

goodluck는 드롭 다운에서 일반 텍스트 파일을 선택합니다!

관련 문제