django-tenant-schemas
django-tenant-schemas copied to clipboard
Unable to run shell for a specifc schema via tenant_command
Environment:
- Python=3.6
- Django=3.0.2
- django-rest-framework=3.11.0
- django-tenant-schemas=1.10.0
I'm having trouble executing the shell command for a specific schema. Here is the command that I'm trying to run:
python manage.py tenant_command shell --schema=<SCHEMA_NAME>
And I'm getting this error:
Traceback (most recent call last):
File "manage.py", line 25, in <module>
main()
File "manage.py", line 21, in main
execute_from_command_line(sys.argv)
File "/home/cypher/.virtualenvs/candi-server/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/cypher/.virtualenvs/candi-server/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/cypher/.virtualenvs/candi-server/lib/python3.6/site-packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/cypher/.virtualenvs/candi-server/lib/python3.6/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/home/cypher/.virtualenvs/candi-server/lib/python3.6/site-packages/tenant_schemas/management/commands/tenant_command.py", line 15, in handle
call_command(command, *args, **options)
File "/home/cypher/.virtualenvs/candi-server/lib/python3.6/site-packages/django/core/management/__init__.py", line 160, in call_command
', '.join(sorted(valid_options)),
TypeError: Unknown option(s) for shell command: skip_checks. Valid options are: command, force_color, help, interface, no_color, no_startup, pythonpath, settings, stderr, stdout, traceback, verbosity, version.
Looks like adding the requires_system_checks
flag and setting it to False
in tenant_command.py
fixes the problem.
class Command(InteractiveTenantOption, BaseCommand):
help = "Wrapper around django commands for use with an individual tenant"
requires_system_checks = False
def handle(self, command, schema_name, *args, **options):
tenant = self.get_tenant_from_options_or_interactive(
schema_name=schema_name, **options
)
connection.set_tenant(tenant)
call_command(command, *args, **options)
Is this issue caused due to #613 ?
Ok, I downgraded to Django v2.2.12 and django-tenant-schemas to 1.9.0 and it also works.
@sshahbaj where I found this file ?
@asrocha Here