Город МОСКОВСКИЙ
00:01:21

__init__() missing 1 required positional argument: 'on_delete'

Аватар
Программирование Практика
Просмотры:
21
Дата загрузки:
02.12.2023 05:38
Длительность:
00:01:21
Категория:
Обучение

Описание

__init__() missing 1 required positional argument: 'on_delete'

-- Add
* on_delete=models.CASCADE


Getting TypeError: __init__() missing 1 required positional argument: 'on_delete' when trying to add parent table after child table with entries.
when I run python manage.py makemigrations my_app_name , I get this error.


Here are some methods can used in on_delete

CASCADE
Cascade deletes. Django emulates the behavior of the SQL constraint ON DELETE CASCADE and also deletes the object containing the ForeignKey

PROTECT
Prevent deletion of the referenced object by raising ProtectedError, a subclass of django.db.IntegrityError.

DO_NOTHING
Take no action. If your database backend enforces referential integrity, this will cause an IntegrityError unless you manually add an SQL ON DELETE constraint to the database field.

Рекомендуемые видео