Friday, June 30, 2017

Re: Django tutorial - Misleading instructions

As Tim said, the APP_DIRS flag enables the app template loader.

https://docs.djangoproject.com/en/1.11/ref/templates/api/#django.template.loaders.app_directories.Loader

"Loads templates from Django apps on the filesystem. For each app in INSTALLED_APPS, the loader looks for a templates subdirectory. If the directory exists, Django looks for templates in there."



El divendres, 30 juny de 2017 3:54:27 UTC+2, Justin Stubbs va escriure:
Hi Guys,

Im following the tutorial https://docs.djangoproject.com/en/1.11/intro/tutorial03/ and have found that the section on templates doesn't appear to be correct.

The section talks about how django templates are loaded by default if you put them in the correct path:





def auth(request):
return render(request, 'g_auth/index.html')



but when I used a similar example django complained about not being able to find the templates. I ended up having to change the django settings file 'DIRS':

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'g_auth/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',
],
},
},
]


Hoping to get this clarified as for a beginner this would be quite complicated(assuming I haven't missed the boat completely here)

Cheers,

Justin

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c7c7c964-b292-41b4-a61b-89761b85aa91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment