Дважды прочитав документацию и прочитав множество псевдо-руководств, я застрял на генерации / расширении шаблонов в Django.
Моя структура проекта:
root
project
templates
base.html
app
templates
child.html
static
imgs
logo.png
На моем settings.js:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, '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',
'social_django.context_processors.backends',
'social_django.context_processors.login_redirect',
],
},
},
]
Мой base.html:
{% load static %}
<html>
<head>
<title>BioPy</title>
<link rel = "stylesheet" href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin = "anonymous">
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin = "anonymous"></script>
<img src = "{% static "imgs/logo.png" %}" alt = "BioPy Logo">
</head>
<body>
<div class = "container">
<div class = "row justify-content-center">
<div class = "col-8">
{% block content %} {% endblock %}
</div>
</div>
</div>
</body>
</html>
Мой child.html:
{% extend "base.html" %}
{% block content %}
<h1 class = "mt-2">Registration</h1>
<hr class = "mt-0 mb-4">
{% load crispy_forms_tags %}
<form method = "post">
{% csrf_token %}
{{ form|crispy }}
<button type = "submit">Sign Up</button>
</form>
{% endblock %}
Получила следующую ошибку:
В упрощенном примере BioPy - это проект, BioPyApp - это приложение, registration.html - дочерний.
С наилучшими пожеланиями,
Я хочу набрать букву «s» на клавиатуре, ти.
Вероятно, вам следует удалить этот вопрос @ AndréGuerra





вы пишете неверный синтаксис, это не {% extend "base.html" %}, это {% extends "base.html" %}
Это
extends, а неextend.