#26401: Allow auth machinery to be used without installing auth app ------------------------------+------------------------------------ Reporter: satchamo | Owner: andkon Type: Bug | Status: closed Component: contrib.auth | Version: 1.9 Severity: Normal | Resolution: wontfix Keywords: auth | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 1 | Patch needs improvement: 0 Easy pickings: 1 | UI/UX: 0 ------------------------------+------------------------------------
Comment (by jdufresne): I found the above to be insufficient. Adding `MIGRATION_MODULES` as the only change to avoid the auth tables fails during migrations with the following trace: {{{ Traceback (most recent call last): File ".../manage.py", line 9, in <module> execute_from_command_line(sys.argv) File ".../venv/lib64/python3.5/site- packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File ".../venv/lib64/python3.5/site- packages/django/core/management/__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File ".../venv/lib64/python3.5/site- packages/django/core/management/base.py", line 305, in run_from_argv self.execute(*args, **cmd_options) File ".../venv/lib64/python3.5/site- packages/django/core/management/base.py", line 356, in execute output = self.handle(*args, **options) File ".../venv/lib64/python3.5/site- packages/django/core/management/commands/migrate.py", line 222, in handle self.verbosity, self.interactive, connection.alias, apps=post_migrate_apps, plan=plan, File ".../venv/lib64/python3.5/site- packages/django/core/management/sql.py", line 53, in emit_post_migrate_signal **kwargs File ".../venv/lib64/python3.5/site- packages/django/dispatch/dispatcher.py", line 191, in send response = receiver(signal=self, sender=sender, **named) File ".../venv/lib64/python3.5/site- packages/django/contrib/auth/management/__init__.py", line 75, in create_permissions "content_type", "codename" File ".../venv/lib64/python3.5/site-packages/django/db/models/query.py", line 256, in __iter__ self._fetch_all() File ".../venv/lib64/python3.5/site-packages/django/db/models/query.py", line 1085, in _fetch_all self._result_cache = list(self.iterator()) File ".../venv/lib64/python3.5/site-packages/django/db/models/query.py", line 125, in __iter__ for row in compiler.results_iter(): File ".../venv/lib64/python3.5/site- packages/django/db/models/sql/compiler.py", line 789, in results_iter results = self.execute_sql(MULTI) File ".../venv/lib64/python3.5/site- packages/django/db/models/sql/compiler.py", line 835, in execute_sql cursor.execute(sql, params) File ".../venv/lib64/python3.5/site- packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File ".../venv/lib64/python3.5/site- packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File ".../venv/lib64/python3.5/site-packages/django/db/utils.py", line 94, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File ".../venv/lib64/python3.5/site-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) File ".../venv/lib64/python3.5/site- packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: relation "auth_permission" does not exist LINE 1: ...ntent_type_id", "auth_permission"."codename" FROM "auth_perm... }}} This fails becuase the auth's `AppConfig` [https://github.com/django/django/blob/38cf9ef390eb0cd0703d99893f826153865f6ba6/django/contrib/auth/apps.py#L15-L18 adds a post_migrate callback] that requires the `auth_permission` table to exist. A project could avoid this by overriding the auth's `AppConfig`. I think this could be easier for projects if the auth's `AppConfig` was split into two classes, one base version that can be used without the auth tables and one that matches the current implementation. This would be a backwards compatible change that would allow the `MIGRATION_MODULES` change noted above. For example: {{{ class BaseAuthConfig(AppConfig): name = 'django.contrib.auth' verbose_name = _("Authentication and Authorization") def ready(self): checks.register(check_user_model, checks.Tags.models) class AuthConfig(BaseAuthConfig): def ready(self): post_migrate.connect( create_permissions, dispatch_uid="django.contrib.auth.management.create_permissions" ) checks.register(check_models_permissions, checks.Tags.models) }}} -- Ticket URL: <https://code.djangoproject.com/ticket/26401#comment:12> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.be9368284635b7a77203dd3163811efa%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.