You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to modify a project to use django-polymorphic-tree.
The project has 4 models (called A, B, C, D) all derived from a base model (called Component). Each A instance contains a set of B items (via FK), and each of those B items contains a set of C items (via FK), each of those C items contains a set of D items. There is another model called T, which as a FK to Component. Each of A, B, C, D items can have a set of T items.
First, it seems the docs/examples are a little out of date (as I get errors with django 3.1.4).
When I try to makemigrations I get errors about mptt fields (level, lft, ...) not having defaults.
How do I handle these?*
$ rm db.sqlite3
$ ./manage.py makemigrations
You are trying to add a non-nullable field 'level' to component without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:
1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
2) Quit, and let me add a default in models.py
NOTE: using Django 3.1.4 with Python 3.7.3 on Debian Buster (10.7) operating system.
Thanks for any help - Brendan.
The text was updated successfully, but these errors were encountered:
I'm trying to modify a project to use
django-polymorphic-tree
.The project has 4 models (called
A
,B
,C
,D
) all derived from a base model (calledComponent
). EachA
instance contains a set ofB
items (via FK), and each of thoseB
items contains a set ofC
items (via FK), each of thoseC
items contains a set ofD
items. There is another model calledT
, which as a FK to Component. Each ofA
,B
,C
,D
items can have a set ofT
items.First, it seems the docs/examples are a little out of date (as I get errors with django 3.1.4).
I added
on_delete=models.SET_NULL
to thePolymorphicTreeForeignKey(...)
statement in thePolymorphicMPTTModel
subclass to solve this. Is this correct?My project was using
django-polymorphic
and I have changed the base class (calledComponent
) as follows.Is that correct?
When I try to
makemigrations
I get errors aboutmptt
fields (level
,lft
, ...) not having defaults.How do I handle these?*
NOTE: using
Django 3.1.4
withPython 3.7.3
onDebian Buster (10.7)
operating system.Thanks for any help - Brendan.
The text was updated successfully, but these errors were encountered: