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

ValueError: Could not find manager MoneyManager in djmoney.models.managers. #666

Open
etarc0s opened this issue Apr 27, 2022 · 1 comment

Comments

@etarc0s
Copy link

etarc0s commented Apr 27, 2022

Hello, when I tried to add a MoneyField in one of my model, I get this error trace:

Traceback (most recent call last):
  File "./manage.py", line 21, in <module>
    main()
  File "./manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/samael/.local/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/home/samael/.local/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/samael/.local/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/samael/.local/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/home/samael/.local/lib/python3.8/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/home/samael/.local/lib/python3.8/site-packages/django/core/management/commands/makemigrations.py", line 172, in handle
    changes = autodetector.changes(
  File "/home/samael/.local/lib/python3.8/site-packages/django/db/migrations/autodetector.py", line 41, in changes
    changes = self._detect_changes(convert_apps, graph)
  File "/home/samael/.local/lib/python3.8/site-packages/django/db/migrations/autodetector.py", line 127, in _detect_changes
    self.new_apps = self.to_state.apps
  File "/home/samael/.local/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/samael/.local/lib/python3.8/site-packages/django/db/migrations/state.py", line 208, in apps
    return StateApps(self.real_apps, self.models)
  File "/home/samael/.local/lib/python3.8/site-packages/django/db/migrations/state.py", line 270, in __init__
    self.render_multiple([*models.values(), *self.real_models])
  File "/home/samael/.local/lib/python3.8/site-packages/django/db/migrations/state.py", line 305, in render_multiple
    model.render(self)
  File "/home/samael/.local/lib/python3.8/site-packages/django/db/migrations/state.py", line 570, in render
    body.update(self.construct_managers())
  File "/home/samael/.local/lib/python3.8/site-packages/django/db/migrations/state.py", line 529, in construct_managers
    as_manager, manager_path, qs_path, args, kwargs = manager.deconstruct()
  File "/home/samael/.local/lib/python3.8/site-packages/django/db/models/manager.py", line 64, in deconstruct
    raise ValueError(
ValueError: Could not find manager MoneyManager in djmoney.models.managers.
Please note that you need to inherit from managers you dynamically generated with 'from_queryset()'.

I have already searched it and found this issue #590 and the response. The problem is that when I use the solution found on the note, which is to encapsulate my custom manager with money_manager, the error persists.

Do you have any idea on how I can solve it ?

@jpic
Copy link

jpic commented May 2, 2022

Workaround: add use_in_migrations = False to your manager class

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

2 participants