Usando o context para enviar dados para dentro dos templates
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user