Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#22535 closed Bug (duplicate)

Lookup failed for model referenced by field accounts.User.groups

Reported by: efrinut@… Owned by: nobody
Component: Migrations Version: 1.7-beta-2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

Traceback (most recent call last):
  File "local_manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "D:\projekty\myinit\env\lib\site-packages\django\core\management\__init__.py", line 427, in execute_from_command_line
    utility.execute()
  File "D:\projekty\myinit\env\lib\site-packages\django\core\management\__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\projekty\myinit\env\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "D:\projekty\myinit\env\lib\site-packages\django\core\management\base.py", line 337, in execute
    output = self.handle(*args, **options)
  File "D:\projekty\myinit\env\lib\site-packages\django\core\management\commands\makemigrations.py", line 99, in handle
    changes = autodetector.changes(graph=loader.graph, trim_to_apps=app_labels or None)
  File "D:\projekty\myinit\env\lib\site-packages\django\db\migrations\autodetector.py", line 33, in changes
    changes = self._detect_changes()
  File "D:\projekty\myinit\env\lib\site-packages\django\db\migrations\autodetector.py", line 50, in _detect_changes
    old_apps = self.from_state.render()
  File "D:\projekty\myinit\env\lib\site-packages\django\db\migrations\state.py", line 63, in render
    model=dangling_lookup[0]))


ValueError: Lookup failed for model referenced by field accounts.User.groups: auth.Group

Printed self.apps._pending_lookups

{('auth', 'Group'): [(
<class '__fake__.User'>,
<django.db.models.fields.related.ManyToManyField: groups>,
<function resolve_related_class at 0x039247F0>),
(<class '__fake__.User'>,
<django.db.models.fields.related.ManyToManyField: groups>,
<function set_managed at 0x03924830>), (<class '__fake__.User_groups'>,
<django.db.models.fields.related.ForeignKey: group>,
<function resolve_related_class at0x03924630>)],
('auth', 'Permission'): [(<class '__fake__.User'>,
<django.db.models.fields.related.ManyToManyField: user_permissions>,
<function resolve_related_class at 0x03924530>),
(<class '__fake__.User'>,
<django.db.models.fields.related.ManyToManyField: user_permissions>,
<function set_managed at 0x03924570>),
(<class '__fake__.User_user_permissions'>,
<django.db.models.fields.related.ForeignKey: permission>,
<function resolve_related_class at 0x039249B0>)]}

Printed dangling dangling_lookup

(('auth', 'Group'), [(<class '__fake__.User'>,
<django.db.models.fields.related.ManyToManyField: groups>,
<function resolve_related_class at 0x039247F0>),
(<class '__fake__.User'>,
<django.db.models.fields.related.ManyToManyField: groups>,
<function set_managed at 0x03924830>),
(<class '__fake__.User_groups'>,
<django.db.models.fields.related.ForeignKey: group>,
<function resolve_related_class at 0x03924630>)])

Change History (3)

comment:1 by Tim Graham, 11 years ago

Description: modified (diff)

Added some formatting (please use preview). I think a minimal set of models to reproduce the issue would be more helpful than the information you have provided so far.

comment:2 by Tim Graham, 11 years ago

Resolution: duplicate
Status: newclosed

Looks like it's probably a duplicate of #22485.

comment:3 by Tim Graham, 11 years ago

Actually it appears to still be an issue and was reported in #22563. I've accepted that ticket.

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