Opened 5 years ago

Closed 5 years ago

#15019 closed (invalid)

register_models is registering models from apps that are not installed

Reported by: yashh Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by russellm)

I am not using django's built in auth models. Instead I wrote a auth app with a user model of my choice. I wrote my own Authentication middleware and it works fine. However when I run django test suite, django is registering models Permission, Message, Group from django.contrib.auth even though "django.contrib.auth" is not mentioned in INSTALLED_APPS. Here is a indetail trace of the test suite

  /Users/yashh/Desktop/costell/manage.py(11)<module>()
-> execute_manager(settings)
  /Library/Python/2.6/site-packages/django/core/management/__init__.py(438)execute_manager()
-> utility.execute()
  /Library/Python/2.6/site-packages/django/core/management/__init__.py(379)execute()
-> self.fetch_command(subcommand).run_from_argv(self.argv)
  /Library/Python/2.6/site-packages/django/core/management/base.py(191)run_from_argv()
-> self.execute(*args, **options.__dict__)
  /Library/Python/2.6/site-packages/django/core/management/base.py(220)execute()
-> output = self.handle(*args, **options)
  /Library/Python/2.6/site-packages/south/management/commands/test.py(8)handle()
-> super(Command, self).handle(*args, **kwargs)
  /Library/Python/2.6/site-packages/django/core/management/commands/test.py(37)handle()
-> failures = test_runner.run_tests(test_labels)
  /Library/Python/2.6/site-packages/django/test/simple.py(314)run_tests()
-> result = self.run_suite(suite)
  /Library/Python/2.6/site-packages/django/test/simple.py(274)run_suite()
-> return DjangoTestRunner(verbosity=self.verbosity, failfast=self.failfast).run(suite)
  /Library/Python/2.6/site-packages/django/test/simple.py(31)run()
-> result = super(DjangoTestRunner, self).run(*args, **kwargs)
  /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py(753)run()
-> test(result)
  /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py(464)__call__()
-> return self.run(*args, **kwds)
  /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py(460)run()
-> test(result)
  /Library/Python/2.6/site-packages/django/test/testcases.py(263)__call__()
-> super(TransactionTestCase, self).__call__(result)
  /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py(300)__call__()
-> return self.run(*args, **kwds)
  /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py(279)run()
-> testMethod()
  /Users/yashh/Desktop/costell/cork/tests.py(17)test_login()
-> response = self.client.get('/login/')
  /Library/Python/2.6/site-packages/django/test/client.py(298)get()
-> response = self.request(**r)
  /Library/Python/2.6/site-packages/django/test/client.py(238)request()
-> response = self.handler(environ)
  /Library/Python/2.6/site-packages/django/test/client.py(79)__call__()
-> response = self.get_response(request)
  /Library/Python/2.6/site-packages/django/core/handlers/base.py(91)get_response()
-> request.path_info)
  /Library/Python/2.6/site-packages/django/core/urlresolvers.py(215)resolve()
-> for pattern in self.url_patterns:
  /Library/Python/2.6/site-packages/django/core/urlresolvers.py(244)_get_url_patterns()
-> patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  /Library/Python/2.6/site-packages/django/core/urlresolvers.py(239)_get_urlconf_module()
-> self._urlconf_module = import_module(self.urlconf_name)
  /Library/Python/2.6/site-packages/django/utils/importlib.py(35)import_module()
-> __import__(name)
  /Users/yashh/Desktop/costell/urls.py(3)<module>()
-> from django.contrib.auth import views as auth_views
  /Library/Python/2.6/site-packages/django/contrib/auth/views.py(7)<module>()
-> from django.contrib.auth.forms import AuthenticationForm
  /Library/Python/2.6/site-packages/django/contrib/auth/forms.py(1)<module>()
-> from django.contrib.auth.models import User
  /Library/Python/2.6/site-packages/django/contrib/auth/models.py(53)<module>()
-> class Permission(models.Model):
  /Library/Python/2.6/site-packages/django/db/models/base.py(193)__new__()
-> register_models(new_class._meta.app_label, new_class)
> /Library/Python/2.6/site-packages/django/db/models/loading.py(197)register_models()

The traceback ends when Permission model is passed to register_models

Change History (1)

comment:1 Changed 5 years ago by russellm

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

There isn't anywhere near enough detail here to work out if what you're describing is a Django problem, or a problem with your own codebase.

A valid test report gives the triager enough data to reproduce your problem on their own. This report has a stack trace, and a vague description that says you've written your own authentication backend.

Please reopen if you can provide enough detail to reproduce the problem. This means a detailed set of instructions, or a sample project (a *minimal* sample project) that exhibits the problem. Don't just dump your entire codebase on our lap -- do some pruning and cut out anything that isn't *directly* related to the problem at hand.

Note: See TracTickets for help on using tickets.
Back to Top