Answer the question
In order to leave comments, you need to log in
Why, when inheriting a template, it is necessary to render not the base template, but the child one? Where is the logic here?
basic index.html template:
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ question }}</title>
</head>
<body>
<h1>Привет</h1>
<a href="#" id="mybtn">кнопка</a>
<h2 id="l1">fffffff</h2>
{% block question %}
qwerqwer
{% endblock %}
<img src="{% static 'img1.jpg' %}" alt="">
<script src="{% static 'js/jquery-3.3.1.min.js' %}"></script>
<script src="{% static 'scripttest.js' %}"></script>
</body>
</html>
{% extends 'mainapp/index.html' %}
{% block title %}question{% endblock %}
{% block question %}
<h2>1</h2>
<h2>2</h2>
<h2>3</h2>
{% endblock %}
def index(request):
return render(request, 'mainapp/one_question.html', {'question': 'Привет'})
def index(request):
return render(request, 'mainapp/index.html', {'question': 'Привет'})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question