forked from heroku/python-getting-started
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
29 lines (23 loc) · 1.02 KB
/
Copy pathviews.py
File metadata and controls
29 lines (23 loc) · 1.02 KB
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
29
from django.shortcuts import render
from .models import Greeting, Visit #<-dodanie Visit
# Create your views here.
def index(request):
# Zapis każdej wizyty w bazie
Visit.objects.create()
#<-dodanie linii
visits = Visit.objects.count() #<-dodanie linii
return render(request, "index.html", {"visits": visits}) #<-dodanie {.....}W
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})