+# coding=utf-8
+
from django.db import models
# Create your models here.
TICKETS_CHOICES = [ (n, n) for n in range(1, 6)]
+TICKET_PRICE=10
+
class Booking(models.Model):
created = models.DateTimeField(auto_now_add=True, editable=False, verbose_name="Datum")
name = models.CharField(max_length=100, verbose_name="Naam")
tickets = models.IntegerField(choices=TICKETS_CHOICES, verbose_name="Aantal kaarten")
show = models.CharField(max_length=50, choices=SHOW_CHOICES, verbose_name="Voorstelling")
payment = models.DateTimeField(blank=True, null=True, verbose_name="Betaling vewerkt op")
+
+ def _get_price(self):
+ return self.tickets * TICKET_PRICE
+ price = property(_get_price)