wildfish/django-gdpr-assist

ValueError: Could not find manager CastPrivacyUserManager in gdpr_assist.models

raratiru opened this issue · 2 comments

In Django-2.1.2 and python 3.5, in a fresh installation I have overriden the User model:

$ ./manage.py startapp community
$ cat community/models.py
from django.contrib.auth.models import AbstractUser
from django.utils.translation import gettext_lazy as _


class Person(AbstractUser):
    def __str__(self):
        return self.username

I add the code:

    class PrivacyMeta:
        fields = ['email', 'first_name', 'last_name']

Navigating to the admin, returns the error:

Exception Type: ProgrammingError at /admin/logout/
Exception Value: column community_person.anonymised does not exist
LINE 1: ...n"."is_active", "community_person"."date_joined", "community...

Trying to make migrations I receive:

Traceback (most recent call last):
  File "./manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/core/management/commands/makemigrations.py", line 170, in handle
    migration_name=self.migration_name,
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/db/migrations/autodetector.py", line 44, in changes
    changes = self._detect_changes(convert_apps, graph)
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/db/migrations/autodetector.py", line 129, in _detect_changes
    self.new_apps = self.to_state.apps
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/db/migrations/state.py", line 210, in apps
    return StateApps(self.real_apps, self.models)
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/db/migrations/state.py", line 271, in __init__
    self.render_multiple(list(models.values()) + self.real_models)
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/db/migrations/state.py", line 306, in render_multiple
    model.render(self)
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/db/migrations/state.py", line 572, in render
    body.update(self.construct_managers())
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/db/migrations/state.py", line 531, in construct_managers
    as_manager, manager_path, qs_path, args, kwargs = manager.deconstruct()
  File "/home/user/.virtualenvs/my-env/lib/python3.5/site-packages/django/db/models/manager.py", line 65, in deconstruct
    % (name, module_name)
ValueError: Could not find manager CastPrivacyUserManager in gdpr_assist.models.
Please note that you need to inherit from managers you dynamically generated with 'from_queryset()'.

Hi, thanks for the bug report! Tracked this down to an issue when a manager needs to be serialised; this hadn't been something we ran into during tests, but has now been fixed in the latest version, 1.0.1.

Thank you, I will start a new project that includes django-gdpr-assist, it seems to be a very useful tool.