-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathviews.py
28 lines (19 loc) · 844 Bytes
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from django.shortcuts import render
from .models import Greeting
# Create your views here.
def index(request):
return render(request, "index.html")
def db(request):
# If you encounter errors visiting the `/db/` page on the example app, check that:
#
# When running the app on Heroku:
# 1. You have added the Postgres database to your app.
# 2. You have uncommented the `psycopg` dependency in `requirements.txt`, and the `release`
# process entry in `Procfile`, git committed your changes and re-deployed the app.
#
# When running the app locally:
# 1. You have run `./manage.py migrate` to create the `hello_greeting` database table.
greeting = Greeting()
greeting.save()
greetings = Greeting.objects.all()
return render(request, "db.html", {"greetings": greetings})