django-tenant-schemas icon indicating copy to clipboard operation
django-tenant-schemas copied to clipboard

Management command fails with latest version

Open abdulMuneerM opened this issue 5 years ago • 5 comments
trafficstars

Tried to run the management command by using tenant_command, but I am getting following error. manage.py tenant_command: error: unrecognized arguments: --username user

It was working before upgrading. How to solve it?

abdulMuneerM avatar Dec 11 '19 07:12 abdulMuneerM

The 1.10.0 release broke it I think... I recommend switching back to 1.9.0 for the moment. The problem lies in https://github.com/bernardopires/django-tenant-schemas/commit/7f72d7af039e6cf2a15520d525636d6e11e72efc#diff-4c79357a33bc89ce66cca6394a8d45bf

This commit prevents taking additional arguments into account...

jeroenbrouwer avatar Dec 11 '19 09:12 jeroenbrouwer

Exactly, I reverted to 1.9.0 for now and it's working fine. Hope the fix will be added on next release.

abdulMuneerM avatar Dec 11 '19 10:12 abdulMuneerM

@goodtune can you take a look at this issue? It basically broke some basic features of this package...

One way to easily add the arguments back would be to do something like the following in InteractiveTenantOption:

def add_arguments(self, parser):
        parser.add_argument("command")
        parser.add_argument(
            "-s", "--schema", dest="schema_name", help="specify tenant schema"
        )
        parser.add_argument("command_args", nargs=argparse.REMAINDER)

and in tenant_command:

def handle(self, command, command_args, schema_name, *args, **options):
        tenant = self.get_tenant_from_options_or_interactive(
            schema_name=schema_name, **options
        )
        connection.set_tenant(tenant)
        call_command(command, *command_args, *args, **options)

jeroenbrouwer avatar Dec 11 '19 11:12 jeroenbrouwer

Pull request welcome.

goodtune avatar Dec 13 '19 20:12 goodtune

In the version 1.10.0, the command changed to:

#python manage.py tenant_command createsuperuser

ivancdechiara avatar May 09 '20 06:05 ivancdechiara