Thursday, June 29, 2017

Re: Django tutorial - Misleading instructions

The 'g_auth/templates' directory should be searched because of 'APP_DIRS': True. Is 'g_auth' in INSTALLED_APPS?

On Thursday, June 29, 2017 at 9:54:27 PM UTC-4, Justin Stubbs wrote:
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/013d969c-6a62-4ec9-bf38-f91b38ec6000%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment