diff --git a/games/__tests__/test_admin.py b/games/__tests__/test_admin.py index 97b4b29..49bac09 100644 --- a/games/__tests__/test_admin.py +++ b/games/__tests__/test_admin.py @@ -89,23 +89,20 @@ def test_latest_added_date_display(self): newer_date = date.today() - timedelta(days=5) # Add game to platform on different dates - gop1 = GameOnPlatform.objects.create( + GameOnPlatform.objects.create( game=game, platform=self.platform, vendor=self.vendor1, + added=older_date, deleted=False, ) - # Set the date after creation to bypass auto_now_add - GameOnPlatform.objects.filter(pk=gop1.pk).update(added=older_date) - - gop2 = GameOnPlatform.objects.create( + GameOnPlatform.objects.create( game=game, platform=self.platform, vendor=self.vendor2, + added=newer_date, deleted=False, ) - # Set the date after creation to bypass auto_now_add - GameOnPlatform.objects.filter(pk=gop2.pk).update(added=newer_date) # Annotate as admin would game = ( @@ -123,16 +120,15 @@ def test_latest_added_date_display_never(self): game = GameFactory(name="Undated Game", platforms=False) # Create GameOnPlatform with added=None - gop = GameOnPlatform.objects.create( + GameOnPlatform.objects.create( game=game, platform=self.platform, vendor=self.vendor1, + added=None, deleted=False, ) - # Set added to None after creation (bypasses auto_now_add) - GameOnPlatform.objects.filter(pk=gop.pk).update(added=None) - # Annotate as admin would - AFTER updating the added field + # Annotate as admin would game = ( Game.objects.all_with_orphaned() .annotate(latest_added=models.Max("platforms_meta_data__added")) diff --git a/games/models.py b/games/models.py index 51c2a48..5f2a059 100644 --- a/games/models.py +++ b/games/models.py @@ -1,4 +1,5 @@ import uuid +from datetime import date from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models @@ -115,7 +116,7 @@ class GameOnPlatform(models.Model): platform = models.ForeignKey( Platform, on_delete=models.CASCADE, related_name="games_meta_data" ) - added = models.DateField(null=True, blank=True, auto_now_add=True) + added = models.DateField(null=True, blank=True, default=date.today) identifier = models.CharField( verbose_name="ID in the platform for generating URLs", max_length=255, diff --git a/jewel/settings.py b/jewel/settings.py index 4f3c13c..83c57b7 100644 --- a/jewel/settings.py +++ b/jewel/settings.py @@ -26,7 +26,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.getenv("JEWEL_DEBUG", "True") == "True" -ALLOWED_HOSTS = os.getenv("JEWEL_ALLOWED_HOSTS", "localhost").split(",") +ALLOWED_HOSTS = os.getenv("JEWEL_ALLOWED_HOSTS", "localhost,127.0.0.1").split(",") # Application definition