Usando o context para enviar dados para dentro dos templates
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Document</title>
|
||||
<title>{{ title }}Site do Luiz</title>
|
||||
<link rel="stylesheet" href="{% static 'home/css/blue.css' %}">
|
||||
<link rel="stylesheet" href="{% static 'global/css/red.css' %}">
|
||||
</head>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{% extends 'global/base.html' %}
|
||||
|
||||
{% block texto %} Exemplo {% endblock texto %}
|
||||
{% block texto %} {{ text }} {% endblock texto %}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{% extends 'global/base.html' %}
|
||||
|
||||
{% block texto %} Blog {% endblock texto %}
|
||||
{% block texto %} {{ text }} {% endblock texto %}
|
||||
|
||||
@@ -4,15 +4,28 @@ from django.shortcuts import render
|
||||
|
||||
def blog(request):
|
||||
print('blog')
|
||||
|
||||
context = {
|
||||
'text': 'Olá blog'
|
||||
}
|
||||
|
||||
return render(
|
||||
request,
|
||||
'blog/index.html'
|
||||
'blog/index.html',
|
||||
context
|
||||
)
|
||||
|
||||
|
||||
def exemplo(request):
|
||||
print('exemplo')
|
||||
|
||||
context = {
|
||||
'text': 'Olá exemplo',
|
||||
'title': 'Essa é uma página de exemplo - ',
|
||||
}
|
||||
|
||||
return render(
|
||||
request,
|
||||
'blog/exemplo.html'
|
||||
'blog/exemplo.html',
|
||||
context
|
||||
)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
{% extends 'global/base.html' %}
|
||||
|
||||
{% block texto %} MUDAR O TEXTO {% endblock texto %}
|
||||
{% block texto %}
|
||||
{{ text }}
|
||||
{% endblock texto %}
|
||||
|
||||
@@ -4,7 +4,12 @@ from django.shortcuts import render
|
||||
def home(request):
|
||||
print('home')
|
||||
|
||||
context = {
|
||||
'text': 'Olá home'
|
||||
}
|
||||
|
||||
return render(
|
||||
request,
|
||||
'home/index.html'
|
||||
'home/index.html',
|
||||
context,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user