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