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!
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:
If you run migrate_schemas you get this:
If you actually run the server you get
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...