Skip to content

Commit

Permalink
Migrate to nonnull (refs #195)
Browse files Browse the repository at this point in the history
  • Loading branch information
Almad committed Dec 29, 2024
1 parent eca53b7 commit 8abfb3f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
21 changes: 21 additions & 0 deletions ddcz/migrations/0007_nonnull_20241229_2201.py
Original file line number Diff line number Diff line change
@@ -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,
),
]
8 changes: 2 additions & 6 deletions ddcz/models/used/social.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 8abfb3f

Please sign in to comment.