Reputation: 2913
In my root directory I have a template and inside that template follow by a base.html
that would be my main layout for my custom admin site.
In my templates/admin/base.html
I have this code.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Layout Page</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
I want this base.html
to be present in all my app templates.
I have an app users
in my mysite
project that its the index.html page.
inside my users/views
.
from django.shortcuts import render
def index(request):
return render(request, 'users/index.html')
Inside my templates/users/index.html
I have this.
{% extends "admin/layout.html" %}
{% block content %}
<h1>Hello World</h1>
{% endblock %}
I get an error:
TemplateDoesNotExist at /
I come from a node.js background so I have no idea if this is even a good practice. I have came across many tutorials explaining the use of templates inside an app but non explaining outside the app.
My understanding was that django bundles all templates into one.
Thanks in advance.
Upvotes: 2
Views: 4441
Reputation: 2913
I figure it out. I need to add the global template my project settings.
'DIRS': [
os.path.join(BASE_DIR, 'templates')
],
Upvotes: 4