Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The basic tutorial does not work. #664

Open
nherriot opened this issue Oct 7, 2020 · 2 comments
Open

The basic tutorial does not work. #664

nherriot opened this issue Oct 7, 2020 · 2 comments

Comments

@nherriot
Copy link

nherriot commented Oct 7, 2020

The tutorial on this page:

https://github.com/bernardopires/django-tenant-schemas/blob/master/docs/examples.rst

Does not work at all. Here are just some of the things that are not mentioned that should be to have something that 'just works' and is easy to learn from. The file does not mention you need to:

  1. Change middle-ware from "tenant_tutorial.middleware.TenantTutorialMiddleware" -to- ""tenant_schemas.middleware.TenantMiddleware".
  2. Change allowed hosts from ALLOWED_HOSTS = ["localhost", ".trendy-sass.com"] -to-ALLOWED_HOSTS = ['*']
  3. Actually run pip install for django-tenant-schemas. It could be that the user would expect this to be explained in the tutorial.
  4. Provide a simple requirements.txt file???
  5. Change the DB engine to: 'tenant_schemas.postgresql_backend'
  6. Run python manage.py migrate_schemas ? Should we do that? Not sure - as i get the errors below in trying to get this working:

If you run migrate you get this:

python manage.py migrate
CommandError: migrate has been disabled, for database 'default'. Use migrate_schemas instead. Please read the documentation if you don't know why you shouldn't call migrate directly!

If you run migrate_schemas you get this:

python manage.py migrate_schemas
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/nherriot/virtualenv/django-tenant-schemas-source/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/nherriot/virtualenv/django-tenant-schemas-source/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/nherriot/virtualenv/django-tenant-schemas-source/lib/python3.6/site-packages/django/core/management/base.py", line 322, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "/home/nherriot/virtualenv/django-tenant-schemas-source/lib/python3.6/site-packages/django/core/management/base.py", line 296, in create_parser
    self.add_arguments(parser)
  File "/home/nherriot/virtualenv/django-tenant-schemas-source/lib/python3.6/site-packages/tenant_schemas/management/commands/migrate_schemas.py", line 20, in add_arguments
    command.add_arguments(parser)
  File "/home/nherriot/virtualenv/django-tenant-schemas-source/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 28, in add_arguments
    help='Skip system checks.',
  File "/usr/lib/python3.6/argparse.py", line 1361, in add_argument
    return self._add_action(action)
  File "/usr/lib/python3.6/argparse.py", line 1724, in _add_action
    self._optionals._add_action(action)
  File "/usr/lib/python3.6/argparse.py", line 1565, in _add_action
    action = super(_ArgumentGroup, self)._add_action(action)
  File "/usr/lib/python3.6/argparse.py", line 1375, in _add_action
    self._check_conflict(action)
  File "/usr/lib/python3.6/argparse.py", line 1514, in _check_conflict
    conflict_handler(action, confl_optionals)
  File "/usr/lib/python3.6/argparse.py", line 1523, in _handle_conflict_error
    raise ArgumentError(action, message % conflict_string)
argparse.ArgumentError: argument --skip-checks: conflicting option string: --skip-checks

If you actually run the server you get

python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 16 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): auth, contenttypes, customers, sessions.
Run 'python manage.py migrate' to apply them.
October 07, 2020 - 08:08:15
Django version 3.1.2, using settings 'tenant_tutorial.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Notice it tells me that I need to run a migration - but I'm unable to do that!

I gave up with this package at this point...

@jywsn
Copy link

jywsn commented Oct 14, 2020

I am also seeing this argparse.ArgumentError when trying to upgrade a project from Django 3.0.8 to Django 3.1.2.

@dani77c
Copy link

dani77c commented Nov 25, 2020

You need to add
requires_system_checks = []
to the class Command(SyncCommon) at migrate_schemas.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants