django-ex/welcome/views.py

19 lines
443 B
Python
Raw Normal View History

2015-05-24 13:56:43 +02:00
import os
2015-05-24 13:10:47 +02:00
from django.shortcuts import render
2015-05-25 20:57:28 +02:00
from django.conf import settings
2015-05-24 13:10:47 +02:00
from . import database
from .models import PageView
2015-05-24 13:10:47 +02:00
# Create your views here.
def index(request):
hostname = os.getenv('HOSTNAME', 'unknown')
PageView.objects.create(hostname=hostname)
2015-05-25 20:57:28 +02:00
2015-05-29 12:23:59 +02:00
return render(request, 'welcome/index.html', {
2015-05-25 20:54:23 +02:00
'hostname': hostname,
'database': database.info(),
'count': PageView.objects.count()
})