Django.fun

TypeError: fromisoformat: argument must be str

[akbar@fedora src]$ ./manage.py migrate

Operations to perform: Apply all migrations: admin, auth, blog, contenttypes, core, product, sessions, users Running migrations: Applying blog.0007_blog_created_at...Traceback (most recent call last): File "/home/akbar/Desktop/Tech/E-commerce-Unistore-Wolves/src/./manage.py", line 22, in main() File "/home/akbar/Desktop/Tech/E-commerce-Unistore-Wolves/src/./manage.py", line 18, in main execute_from_command_line(sys.argv) File "/home/akbar/.local/lib/python3.10/site-packages/django/core/management/init.py", line 446, in execute_from_command_line utility.execute() File "/home/akbar/.local/lib/python3.10/site-packages/django/core/management/init.py", line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/akbar/.local/lib/python3.10/site-packages/django/core/management/base.py", line 414, in run_from_argv self.execute(*args, **cmd_options) File "/home/akbar/.local/lib/python3.10/site-packages/django/core/management/base.py", line 460, in execute output = self.handle(*args, **options) File "/home/akbar/.local/lib/python3.10/site-packages/django/core/management/base.py", line 98, in wrapped res = handle_func(*args, **kwargs) File "/home/akbar/.local/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 290, in handle post_migrate_state = executor.migrate( File "/home/akbar/.local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 131, in migrate state = self._migrate_all_forwards( File "/home/akbar/.local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 163, in _migrate_all_forwards state = self.apply_migration( File "/home/akbar/.local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 248, in apply_migration state = migration.apply(state, schema_editor) File "/home/akbar/.local/lib/python3.10/site-packages/django/db/migrations/migration.py", line 131, in apply operation.database_forwards( File "/home/akbar/.local/lib/python3.10/site-packages/django/db/migrations/operations/fields.py", line 108, in database_forwards schema_editor.add_field( File "/home/akbar/.local/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 599, in add_field definition, params = self.column_sql(model, field, include_default=True) File "/home/akbar/.local/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 345, in column_sql " ".join( File "/home/akbar/.local/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 296, in _iter_column_sql default_value = self.effective_default(field) File "/home/akbar/.local/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 410, in effective_default return field.get_db_prep_save(self._effective_default(field), self.connection) File "/home/akbar/.local/lib/python3.10/site-packages/django/db/models/fields/init.py", line 910, in get_db_prep_save return self.get_db_prep_value(value, connection=connection, prepared=False) File "/home/akbar/.local/lib/python3.10/site-packages/django/db/models/fields/init.py", line 1408, in get_db_prep_value value = self.get_prep_value(value) File "/home/akbar/.local/lib/python3.10/site-packages/django/db/models/fields/init.py", line 1403, in get_prep_value return self.to_python(value) File "/home/akbar/.local/lib/python3.10/site-packages/django/db/models/fields/init.py", line 1359, in to_python parsed = parse_date(value) File "/home/akbar/.local/lib/python3.10/site-packages/django/utils/dateparse.py", line 74, in parse_date return datetime.date.fromisoformat(value) TypeError: fromisoformat: argument must be str

my blog.models:

class Blog(models.Model):
title = models.CharField(max_length=150)
description = models.TextField()
image = models.ImageField(upload_to="uploads/%Y/%m/%d/", null=True)
slug = models.SlugField(null=True)
created_at = models.DateField(auto_now_add=True, null=True)
tags = models.ManyToManyField(
    "blog.Tag",
)
comment = models.ForeignKey(
    'blog.comment',
     on_delete=models.CASCADE,
     null=True)

def get_absolute_url(self):
    return reverse("blog/detail", kwargs={"slug": self.slug})

def __str__(self) -> str:
    return f"{self.created_at.strftime('%d-%m-%Y')}"

Tutorials

Константы Python: Улучшение управляемости вашего кода

Современный Python: начинаем проект с pyenv и poetry

Настройка проекта Python — виртуальные среды и управление пакетами

Использование requests в Python — тайм-ауты, повторы, хуки

Понимание декораторов в Python

ProcessPoolExecutor в Python: полное руководство

map() против submit() с ProcessPoolExecutor в Python

Понимание атрибутов, словарей и слотов в Python

Полное руководство по slice в Python

Выпуск Django 4.0

Безопасное развертывание приложения Django с помощью Gunicorn, Nginx и HTTPS

Автоматический повтор невыполненных задач Celery

Django REST Framework и Elasticsearch

Докеризация Django с помощью Postgres, Gunicorn и Nginx

Асинхронные задачи с Django и Celery

Релизы безопасности Django: 3.2.4, 3.1.12 и 2.2.24

Выпуски исправлений ошибок Django: 3.2.3, 3.1.11 и 2.2.23

Эффективное использование сериализаторов Django REST Framework

Выпуски безопасности Django: 3.2.2, 3.1.10 и 2.2.22

Выпущенные релизы безопасности Django: 3.2.1, 3.1.9 и 2.2.21

View all tutorials →