django-scopes icon indicating copy to clipboard operation
django-scopes copied to clipboard

dumpdata command is also affected

Open limugob opened this issue 5 years ago • 5 comments

Hello,

the dumpdata command does not work with scopes. So I disabled scopes for this command.

from django.core.management.commands.dumpdata import Command as DumpdataCommand
from django_scopes import scopes_disabled


class Command(DumpdataCommand):
    def handle(self, *args, **options):
        with scopes_disabled():
            return super().handle(*args, **options)

maybe it can be included?

limugob avatar Jun 09 '20 13:06 limugob

I'm not sure if overriding a default Django manage command in an installed app is a great idea, as it would interfere with other apps doing the same thing. Maybe we should instead include your solution in the docs instead?

rixx avatar Jun 09 '20 14:06 rixx

Describing in docs would be good. But I think that, when the package django-scopes breaks this command, it should patch it. Other commands are also affected like datamigrations and shell - like the docs mention, but they work generally, it depend from usage how much the effects are. dumpdata is simply broken.

limugob avatar Jun 11 '20 06:06 limugob

I'm not sure if overriding a default Django manage command in an installed app is a great idea

Channels does it with runserver, so there's at least precedent ;) But I'm also not a fan. A more general solution could be recommending something like a manage_unscoped.py?

raphaelm avatar Jun 11 '20 08:06 raphaelm

Is there a workaround to scope the "dumpdata" command? `python manage.py dumpdata master.endnode

[CommandError: Unable to serialize database: A scope on dimension(s) org needs to be active for this query.`

krisdthompson avatar Apr 20 '22 12:04 krisdthompson

Yes, the workaround is in the original description of this issue :)

raphaelm avatar Apr 20 '22 12:04 raphaelm