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

Django 1.8 #252

Closed
tomturner opened this issue Apr 3, 2015 · 9 comments
Closed

Django 1.8 #252

tomturner opened this issue Apr 3, 2015 · 9 comments

Comments

@tomturner
Copy link

As Django 1.8 is out. I have just tried django-tenant-schemas example and it doesn't work.

When running python manage.py migrate_schemas I get the following error

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/tenant_schemas/management/commands/migrate_schemas.py", line 24, in run_from_argv
    super(MigrateSchemasCommand, self).run_from_argv(argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/tenant_schemas/management/commands/migrate_schemas.py", line 34, in handle
    self.run_migrations(self.schema_name, settings.SHARED_APPS)
  File "/usr/local/lib/python2.7/dist-packages/tenant_schemas/management/commands/migrate_schemas.py", line 61, in run_migrations
    command.execute(*self.args, **defaults)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 70, in handle
    connection = connections[db]
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 234, in __getitem__
    if hasattr(self._connections, alias):
TypeError: hasattr(): attribute name must be string

And if I take an existing project from 1.7 and do run sever I get

System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0xb617ca04>
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 223, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 112, in inner_run
    self.check_migrations()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 164, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 19, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 47, in __init__
    self.build_graph()
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 180, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 59, in applied_migrations
    self.ensure_schema()
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 49, in ensure_schema
    if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/introspection.py", line 58, in table_names
    return get_names(cursor)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/introspection.py", line 53, in get_names
    return sorted(ti.name for ti in self.get_table_list(cursor)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/introspection.py", line 54, in <genexpr>
    if include_views or ti.type == 't')
AttributeError: 'unicode' object has no attribute 'type' 
@dkvdm
Copy link

dkvdm commented Apr 5, 2015

I run into the same problem, does anyone know how to fix the migrate command under 1.8? Thanks!
Edit: tested with "dts_test_project", same result for easy reproducing

FLX@FLXs-MacBook-Pro ~/django-tenant-schemas/dts_test_project $   python manage.py migrate_schemas --shared
/Users/FLX/.virtualenvs/attendy/lib/python2.7/site-packages/tenant_schemas/utils.py:4: RemovedInDjango19Warning: The utilities in django.db.models.loading are deprecated in favor of the new application loading system.
  from django.db.models.loading import get_model

/Users/FLX/.virtualenvs/attendy/lib/python2.7/site-packages/tenant_schemas/postgresql_backend/base.py:4: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
  from django.utils.importlib import import_module

=== Running migrate for schema public
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/FLX/.virtualenvs/attendy/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/Users/FLX/.virtualenvs/attendy/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/FLX/.virtualenvs/attendy/lib/python2.7/site-packages/tenant_schemas/management/commands/migrate_schemas.py", line 24, in run_from_argv
    super(MigrateSchemasCommand, self).run_from_argv(argv)
  File "/Users/FLX/.virtualenvs/attendy/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/FLX/.virtualenvs/attendy/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/Users/FLX/.virtualenvs/attendy/lib/python2.7/site-packages/tenant_schemas/management/commands/migrate_schemas.py", line 34, in handle
    self.run_migrations(self.schema_name, settings.SHARED_APPS)
  File "/Users/FLX/.virtualenvs/attendy/lib/python2.7/site-packages/tenant_schemas/management/commands/migrate_schemas.py", line 61, in run_migrations
    command.execute(*self.args, **defaults)
  File "/Users/FLX/.virtualenvs/attendy/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/Users/FLX/.virtualenvs/attendy/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 70, in handle
    connection = connections[db]
  File "/Users/FLX/.virtualenvs/attendy/lib/python2.7/site-packages/django/db/utils.py", line 234, in __getitem__
    if hasattr(self._connections, alias):
TypeError: hasattr(): attribute name must be string

@dkvdm
Copy link

dkvdm commented Apr 6, 2015

Sweet! Care to create a pull request @tomturner ?

@tomturner
Copy link
Author

The problem with the fix is that it will not work with Django 1.7 or below.

FYI I missed a commit which i have now uploaded

@mickeyckm
Copy link

Any chance this will be fix soon?

@tomturner
Copy link
Author

I have now created a pull request for Django 1.8 as I just made it work for Django 1.7 etc

@brechmos
Copy link

@tomturner thank you for fixing this. Very helpful as I am just trying out python3.4 and django1.8 with tenant schemas (which is awesome).

@ablochs
Copy link

ablochs commented Jul 24, 2015

hey @tomturner, the link seems to be broken tomturner@fe437f7

im trying to make it work with django 1.8...

@ablochs
Copy link

ablochs commented Jul 24, 2015

ok found it... c80f5a2

@bernardopires
Copy link
Owner

Support for django 1.8 has been added. Thanks @tomturner.

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

6 participants