From 8abfb3f44e4d1d137dbba961e67f045eaa94306b Mon Sep 17 00:00:00 2001 From: Almad Date: Sun, 29 Dec 2024 22:02:10 +0100 Subject: [PATCH] Migrate to nonnull (refs #195) --- ddcz/migrations/0007_nonnull_20241229_2201.py | 21 +++++++++++++++++++ ddcz/models/used/social.py | 8 ++----- 2 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 ddcz/migrations/0007_nonnull_20241229_2201.py diff --git a/ddcz/migrations/0007_nonnull_20241229_2201.py b/ddcz/migrations/0007_nonnull_20241229_2201.py new file mode 100644 index 0000000..1a0fb09 --- /dev/null +++ b/ddcz/migrations/0007_nonnull_20241229_2201.py @@ -0,0 +1,21 @@ +# Generated by Django 3.1.14 on 2024-12-29 21:01 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("ddcz", "0006_dates_vol2"), + ] + + operations = [ + migrations.AlterField( + model_name="market", + name="created", + field=models.DateTimeField( + default=datetime.datetime(2000, 1, 1, 0, 0), verbose_name="Přidáno" + ), + preserve_default=False, + ), + ] diff --git a/ddcz/models/used/social.py b/ddcz/models/used/social.py index ac86b14..c7de5af 100644 --- a/ddcz/models/used/social.py +++ b/ddcz/models/used/social.py @@ -92,18 +92,14 @@ class Market(models.Model): max_length=12, db_column="datum", verbose_name="Přidáno" ) - created = models.DateTimeField(blank=True, null=True, verbose_name="Přidáno") + created = models.DateTimeField(verbose_name="Přidáno") def __str__(self): return f"{self.name} ({self.group}) z {self.published}" @property def published(self): - # Windows workaround as `%-d` is platform-specific - try: - return date(*(strptime(self.published_varchar, "%-d. %-m. %Y")[0:3])) - except ValueError: - return date(*(strptime(self.published_varchar, "%d. %m. %Y")[0:3])) + return self.created class Meta: db_table = "inzerce"