Open maxwellcc opened 4 years ago
I'm having the same issue with Django 3.1 and DTS 1.10.0.
I discovered the reason for the problem. This error occurs in versions of Django greater than 3.0.9. So, I downgraded from version 3.1 to version 3.0.9
Hi guys, I am having the same problem too using Django 3.1
and DTS 1.10.0
.
I looked around and realized that it has something to do with the changes in Django related to the skip_checks
command option.
First, in https://github.com/django/django/commit/6866c91b638de5368c18713fa851bfe56253ea55
--skip-check
was introduced in Django BaseCommand
causing the argument to be added twice since migrate
adds it too. So to prevent the issue, requires_system_checks
has to be set to False
Now, https://code.djangoproject.com/ticket/31546 and https://github.com/django/django/pull/12910
introduced the notion of specific system checks. So requires_system_checks = []
is the new way of setting it to false
That said, here are different solutions/workarounds I found
1 - Add requires_system_checks = []
to migrate_schemas
command class
class Command(SyncCommon):
requires_system_checks = []
...
2 - Or customize BaseCommand.create_parser(prog_name, subcommand, **kwargs)
to tell arg parser not to raise an exception when an argument is defined twice. (https://docs.python.org/3/library/argparse.html#conflict-handler)
class Command(SyncCommon):
...
def create_parser(self, prog_name, subcommand, **kwargs):
return super().create_parser(prog_name, subcommand, **{**kwargs, 'conflict_handler': 'resolve'})
...
I am more inclined to go with solution 1, I will make a PR with that. Please let me know what you think or if there is an even better way to approach it, I wouldn't say I have a complete picture this is the first time I am using DTS.
In the meantime, you can locally override the migrate_schemas
command to add the fix locally following https://docs.djangoproject.com/en/3.0/howto/custom-management-commands/
from tenant_schemas.management.commands.migrate_schemas import Command as MigrateSchemasCommand
class Command(MigrateSchemasCommand):
requires_system_checks = []
Are all these issues related? #641 #634 #613
@goodtune
Aun existe este problema, entonce la solucion es bajar la version de Django, o existe otra solución?
Hi guys, I am having the same problem too using
Django 3.1
andDTS 1.10.0
.I looked around and realized that it has something to do with the changes in Django related to the
skip_checks
command option.
- First, in django/django@6866c91
--skip-check
was introduced inDjango BaseCommand
causing the argument to be added twice sincemigrate
adds it too. So to prevent the issue,requires_system_checks
has to be set toFalse
- Now, https://code.djangoproject.com/ticket/31546 and django/django#12910 introduced the notion of specific system checks. So
requires_system_checks = []
is the new way of setting it to falseThat said, here are different solutions/workarounds I found
1 - Add
requires_system_checks = []
tomigrate_schemas
command classclass Command(SyncCommon): requires_system_checks = [] ...
2 - Or customize
BaseCommand.create_parser(prog_name, subcommand, **kwargs)
to tell arg parser not to raise an exception when an argument is defined twice. (https://docs.python.org/3/library/argparse.html#conflict-handler)class Command(SyncCommon): ... def create_parser(self, prog_name, subcommand, **kwargs): return super().create_parser(prog_name, subcommand, **{**kwargs, 'conflict_handler': 'resolve'}) ...
I am more inclined to go with solution 1, I will make a PR with that. Please let me know what you think or if there is an even better way to approach it, I wouldn't say I have a complete picture this is the first time I am using DTS.
In the meantime, you can locally override the
migrate_schemas
command to add the fix locally following https://docs.djangoproject.com/en/3.0/howto/custom-management-commands/from tenant_schemas.management.commands.migrate_schemas import Command as MigrateSchemasCommand class Command(MigrateSchemasCommand): requires_system_checks = []
Thanks first solution worked for me
Using in requirements.txt
Django==3.1
django-tenant-schemas==1.10.0
In settings.py