Reputation: 355
I have some trouble getting my templates to work. Overall very unsure how to setup the static files and templates in my project directory.
Should I as best practice place my templates inside the app folder when under development and my static files inside the app folder as well?
This is the output:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
/Users/username/Dev/test_dev_01/projects/test/main/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/tinymce/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/mce_filebrowser/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/django/contrib/auth/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/django/contrib/sitemaps/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/mezzanine/conf/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/mezzanine/core/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/mezzanine/generic/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/mezzanine/pages/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/mezzanine/blog/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/mezzanine/forms/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/mezzanine/galleries/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/mezzanine/accounts/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/avatar/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/filebrowser_safe/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/grappelli_safe/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/django/contrib/admin/templates/main/templates/index.html (File does not exist)
/Users/username/Dev/test_dev_01/lib/python3.4/site-packages/django_comments/templates/main/templates/index.html (File does not exist)
urls.py:
url(r"^$", "main.views.home", name="home"),
views.py:
def home(request):
return render(request, "main/templates/index.html", context)
settings.py:
PROJECT_APP_PATH = os.path.dirname(os.path.abspath(__file__))
PROJECT_APP = os.path.basename(PROJECT_APP_PATH)
PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
#os.path.join(PROJECT_ROOT, 'templates')
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
# Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
# list if you haven't customized them:
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.static",
"django.core.context_processors.media",
"django.core.context_processors.request",
"django.core.context_processors.tz",
"mezzanine.conf.context_processors.settings",
"mezzanine.pages.context_processors.page",
"main.context_processors.global_settings",
],
},
},
]
What could be the cause of this? I can't figure it out.
Upvotes: 0
Views: 88
Reputation: 16671
I'm just deducing this because you have not provided this information:
main
index.html
is really located at:
/Users/username/Dev/test_dev_01/projects/test/main/templates/index.html
If my presumptions are correct, your call to render should read:
def home(request):
return render(request, "index.html", context)
Upvotes: 2