| @ -0,0 +1,21 @@ | |||||
| # -*- coding: utf-8 -*- | |||||
| from __future__ import unicode_literals | |||||
| from django.db import models, migrations | |||||
| class Migration(migrations.Migration): | |||||
| dependencies = [ | |||||
| ] | |||||
| operations = [ | |||||
| migrations.CreateModel( | |||||
| name='PageView', | |||||
| fields=[ | |||||
| ('id', models.AutoField(verbose_name='ID', auto_created=True, serialize=False, primary_key=True)), | |||||
| ('hostname', models.CharField(max_length=32)), | |||||
| ('timestamp', models.DateTimeField(auto_now_add=True)), | |||||
| ], | |||||
| ), | |||||
| ] | |||||
| @ -1,3 +1,7 @@ | |||||
| from django.db import models | from django.db import models | ||||
| # Create your models here. | # Create your models here. | ||||
| class PageView(models.Model): | |||||
| hostname = models.CharField(max_length=32) | |||||
| timestamp = models.DateTimeField(auto_now_add=True) | |||||
| @ -1,7 +1,14 @@ | |||||
| import os | import os | ||||
| from django.shortcuts import render | from django.shortcuts import render | ||||
| from .models import PageView | |||||
| # Create your views here. | # Create your views here. | ||||
| def index(request): | def index(request): | ||||
| return render(request, 'openshift/index.html', {'HOSTNAME': os.getenv('HOSTNAME', 'unknown')}) | |||||
| hostname = os.getenv('HOSTNAME', 'unknown') | |||||
| PageView.objects.create(hostname=hostname) | |||||
| return render(request, 'openshift/index.html', { | |||||
| 'HOSTNAME': hostname, | |||||
| 'count': PageView.objects.count() | |||||
| }) | |||||