I have a use case where I don't want the mdoel._default_manager to be moderated.
I am limiting moderation-affected querysets by Moderator.manager_names and I am using moderated managers explicitly in my code only where I need them.
Unfortunately, regrdless of limiting via manager_names, django-moderation overtakes the model._default_manager and I can not create objects with foreign key to moderated model for objects that haven't been approved yet (having visible=False).
Here is a sketch of my models:
class Artwork(ModeratedModel, models.Model):
objects = models.Manager()
moderated_objects = models.Manager() # only this one should be moderated
class Meta:
manager_names = ["moderated_objects"] # I don't want `objects` to be affected, i.e. the default manager too!
visibility_column = "visible"
class Photo(models.Model):
artwork = ForeignKey(Artwork)
And the usage:
>>> artwork = Artwork.objects.create() # has visible = False, is excluded from moderated queryset
>>> photo = Photo.objects.create(artwork=artwork)
Traceback (most recent call last):
File "...."
ArtworkDoesNotExist: ...
I have a use case where I don't want the
mdoel._default_manager
to be moderated.I am limiting moderation-affected querysets by
Moderator.manager_names
and I am using moderated managers explicitly in my code only where I need them.Unfortunately, regrdless of limiting via
manager_names
, django-moderation overtakes themodel._default_manager
and I can not create objects with foreign key to moderated model for objects that haven't been approved yet (having visible=False).Here is a sketch of my models:
And the usage:
This happens because django validates
Photo.artist
field withArtist
's _default_manager: https://docs.djangoproject.com/en/3.2/topics/db/managers/#django.db.models.Model._default_manager which is moderated, thus fails (until artist was approved).