bernardopires / django-tenant-schemas

Tenant support for Django using PostgreSQL schemas.
https://django-tenant-schemas.readthedocs.org/en/latest/
MIT License
1.46k stars 424 forks source link

ValueError: Dependency on unknown app: customauth #263

Open brechmos opened 9 years ago

brechmos commented 9 years ago

I am trying to create a project with a custom User in Django 1.8 and Python 3.4 with django-tenant-schemas. (I am using git+https://github.com/tomturner/django-tenant-schemas.git as it has a fix for what appears to be another bug I had run into).

The customauth/models.py and customauth/admin.py are copies directly off of the Django 1.8 webpage.

I followed the setup for django-tenant-schemas and the main part is:

TENANT_MODEL = "customers.Client"
AUTH_USER_MODEL = 'customauth.MyUser'

# Application definition

SHARED_APPS = (
    'tenant_schemas',  # mandatory
    'customers', # you must list the app where your tenant model resides in

    'django.contrib.contenttypes',

    # everything below here is optional
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.admin',
)

TENANT_APPS = (
    # The following Django contrib apps must be in TENANT_APPS
    'django.contrib.contenttypes',

    # your tenant-specific apps
    'customauth',
)

INSTALLED_APPS = list(set(SHARED_APPS + TENANT_APPS))

The problem when I do a python manage.py makemigrations I get the following error:

$ python manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/odroid/Documents/django/thetest/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/odroid/Documents/django/thetest/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/odroid/Documents/django/thetest/env/lib/python3.4/site-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/odroid/Documents/django/thetest/env/lib/python3.4/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/home/odroid/Documents/django/thetest/env/lib/python3.4/site-packages/django/core/management/commands/makemigrations.py", line 63, in handle
    loader = MigrationLoader(None, ignore_no_migrations=True)
  File "/home/odroid/Documents/django/thetest/env/lib/python3.4/site-packages/django/db/migrations/loader.py", line 47, in __init__
    self.build_graph()
  File "/home/odroid/Documents/django/thetest/env/lib/python3.4/site-packages/django/db/migrations/loader.py", line 287, in build_graph
    parent = self.check_key(parent, key[0])
  File "/home/odroid/Documents/django/thetest/env/lib/python3.4/site-packages/django/db/migrations/loader.py", line 165, in check_key
    raise ValueError("Dependency on unknown app: %s" % key[0])
ValueError: Dependency on unknown app: customauth

If I comment out the AUTH_USER_MODEL = 'customauth.MyUser' line then everything appears to run correctly.

$ python manage.py makemigrations
Migrations for 'customauth':
  0001_initial.py:
    - Create model MyUser
(env)odroid@odroid:~/Documents/django/thetest$ python manage.py makemigrations
No changes detected
(env)odroid@odroid:~/Documents/django/thetest$ python manage.py migrate_schemas --shared
=== Running migrate for schema public
Operations to perform:
  Synchronize unmigrated apps: messages, customers, tenant_schemas
  Apply all migrations: auth, contenttypes, admin, sessions, customauth, sites
Synchronizing apps without migrations:
  Creating tables...
    Creating table customers_client
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying customauth.0001_initial... OK
  Applying sessions.0001_initial... OK
  Applying sites.0001_initial... OK

So, what might I be doing wrong? Any help or ideas would be greatly appreciated.

Leeaandrob commented 6 years ago

I have similar issue, I need that the table of auth similar the your stay on Tenant_Apps and not on the shared, how can i do this?