Skip to content

Commit

Permalink
fix(models): allow generic foreign key to be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Nov 11, 2024
1 parent a7ff54a commit 7da8692
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.1.2 on 2024-11-11 09:26

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('apis_instance_nsvis', '0001_initial'),
('contenttypes', '0002_remove_content_type_name'),
]

operations = [
migrations.AlterField(
model_name='mongodbmodel',
name='content_type',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype'),
),
migrations.AlterField(
model_name='mongodbmodel',
name='object_id',
field=models.PositiveIntegerField(null=True),
),
]
4 changes: 2 additions & 2 deletions apis_instance_nsvis/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class NsvisMixin:
class MongoDbModel(models.Model):
data = models.JSONField()
filename = models.TextField(blank=False, max_length=32)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, null=True)
object_id = models.PositiveIntegerField(null=True)
content_object = GenericForeignKey("content_type", "object_id")


Expand Down

0 comments on commit 7da8692

Please sign in to comment.