From 18b3f45b79c01915310b619038afdf09721669ea Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 22 Sep 2020 11:33:17 +0300 Subject: [PATCH] Collection main_item: make a OneToOneField intsead of just a foreign key. --- .../migrations/0030_auto_20200922_0832.py | 19 +++++++++++++++++++ django_etebase/models.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 django_etebase/migrations/0030_auto_20200922_0832.py diff --git a/django_etebase/migrations/0030_auto_20200922_0832.py b/django_etebase/migrations/0030_auto_20200922_0832.py new file mode 100644 index 0000000..d5fa95d --- /dev/null +++ b/django_etebase/migrations/0030_auto_20200922_0832.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.1 on 2020-09-22 08:32 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('django_etebase', '0029_auto_20200907_0801'), + ] + + operations = [ + migrations.AlterField( + model_name='collection', + name='main_item', + field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='parent', to='django_etebase.collectionitem'), + ), + ] diff --git a/django_etebase/models.py b/django_etebase/models.py index 797aa0f..d3405f1 100644 --- a/django_etebase/models.py +++ b/django_etebase/models.py @@ -28,7 +28,7 @@ UidValidator = RegexValidator(regex=r'^[a-zA-Z0-9\-_]{20,}$', message='Not a val class Collection(models.Model): - main_item = models.ForeignKey('CollectionItem', related_name='parent', null=True, on_delete=models.SET_NULL) + main_item = models.OneToOneField('CollectionItem', related_name='parent', null=True, on_delete=models.SET_NULL) owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) def __str__(self):