Я младший разработчик, и я пытаюсь установить патч django.contrib.auth.models
Менеджер группы.(Python 2.7.15, Django 1.8)
Вот мой код:
class DefaultGroupManager(models.Manager):
def get_queryset(self):
tests = Test.objects.values()
tests_ids = [test['virtual_group_id'] for test in tests]
return super(DefaultGroupManager, self).get_queryset().exclude(id__in=tests_ids)
Group.objects = DefaultGroupManager()
Затем я открываю оболочку python для проверки:
python manage.py shell
из django.contrib.auth.models import Group
t = Group.objects.all ()
Сразу после этой команды я получаюошибка:
File "<console>", line 1, in <module>
File "/home/adrian/Dokumenty/Pycharm Projects/backend/venv/local/lib/python2.7/site-packages/django/db/models/manager.py", line 228, in all
return self.get_queryset()
File "/home/adrian/Dokumenty/Pycharm Projects/backend/registration/models.py", line 13, in get_queryset
return super(DefaultGroupManager, self).get_queryset().exclude(id__in=tests_ids)
File "/home/adrian/Dokumenty/Pycharm Projects/backend/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 686, in exclude
return self._filter_or_exclude(True, *args, **kwargs)
File "/home/adrian/Dokumenty/Pycharm Projects/backend/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 695, in _filter_or_exclude
clone.query.add_q(~Q(*args, **kwargs))
File "/home/adrian/Dokumenty/Pycharm Projects/backend/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1310, in add_q
clause, require_inner = self._add_q(where_part, self.used_aliases)
File "/home/adrian/Dokumenty/Pycharm Projects/backend/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1338, in _add_q
allow_joins=allow_joins, split_subq=split_subq,
File "/home/adrian/Dokumenty/Pycharm Projects/backend/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1150, in build_filter
lookups, parts, reffed_expression = self.solve_lookup_type(arg)
File "/home/adrian/Dokumenty/Pycharm Projects/backend/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1036, in solve_lookup_type
_, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
File "/home/adrian/Dokumenty/Pycharm Projects/backend/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 246, in get_meta
return self.model._meta
AttributeError: 'NoneType' object has no attribute '_meta'
Понятия не имею, что не так: (
Буду признателен за любую помощь!