Renderizando HTML, render, templates, INSTALLED_APPS e TemplateDoesNotExist

This commit is contained in:
Luiz Otávio
2023-04-16 17:19:27 -03:00
parent e2be22efd8
commit e3577a686b
6 changed files with 53 additions and 8 deletions

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<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>
</head>
<body>
<h1>EXEMPLO 2</h1>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<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>
</head>
<body>
<h1>BLOG 2</h1>
</body>
</html>

View File

@@ -1,13 +1,18 @@
from django.http import HttpResponse
# from django.shortcuts import render
from django.shortcuts import render
def blog(request):
print('blog')
return HttpResponse('blog do app 1')
return render(
request,
'blog/index.html'
)
def exemplo(request):
print('exemplo')
return HttpResponse('exemplo do app 1')
return render(
request,
'blog/exemplo.html'
)

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<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>
</head>
<body>
<h1>HOME 2</h1>
</body>
</html>

View File

@@ -1,8 +1,10 @@
from django.http import HttpResponse
# from django.shortcuts import render
from django.shortcuts import render
def home(request):
print('home')
return HttpResponse('home do app 1')
return render(
request,
'home/index.html'
)

View File

@@ -37,6 +37,8 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'home',
'blog',
]
MIDDLEWARE = [