diff --git a/apps/accounts/models/hosting.py b/apps/accounts/models/hosting.py index 1a8ac8cd..0ea6c5c1 100644 --- a/apps/accounts/models/hosting.py +++ b/apps/accounts/models/hosting.py @@ -846,7 +846,7 @@ class Meta: class HostingproviderStats(models.Model): - hostingprovider = models.ForeignKey( + hostingprovider = models.OneToOneField( Hostingprovider, on_delete=models.CASCADE, db_column="id_hp", diff --git a/apps/greencheck/models/stats.py b/apps/greencheck/models/stats.py index 125750ea..e0c682ba 100644 --- a/apps/greencheck/models/stats.py +++ b/apps/greencheck/models/stats.py @@ -17,8 +17,12 @@ logger = logging.getLogger(__name__) -now = timezone.now() -yesterday = now - relativedelta(days=1) +def yesterday(): + """Return the the day before today. + Used as default value for date fields. + """ + now = timezone.now() + return now - relativedelta(days=1) class Stats(models.Model):