essensplan/cal/models.py

13 lines
645 B
Python

from django.db import models
from django.urls import reverse
class Event(models.Model):
date = models.DateField()
brekky = models.CharField(max_length=255, blank=True, null=True)
lunch = models.CharField(max_length=255, blank=True, null=True)
dinner = models.CharField(max_length=255, blank=True, null=True)
@property
def get_html_url(self):
url = reverse('cal:event_edit', args=(self.id,))
return f'<a href="{url}" style="color:burlywood;"> {self.brekky or "-"} </a><br/><a href="{url}" style="color:blue;"> {self.lunch or "-"} </a><br/><a href="{url}" style="color:green;"> {self.dinner or "-"} </a>'