{"action":"created","issue":{"url":"https://api.github.com/repos/makinacorpus/django-safedelete/issues/38","labels_url":"https://api.github.com/repos/makinacorpus/django-safedelete/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/makinacorpus/django-safedelete/issues/38/comments","events_url":"https://api.github.com/repos/makinacorpus/django-safedelete/issues/38/events","html_url":"https://github.com/makinacorpus/django-safedelete/pull/38","id":117839828,"number":38,"title":"prevent migration errors on django 1.8 by declaring the SafeDeleteManager (internal class in managers) as global","user":{"login":"barseghyanartur","id":4925587,"avatar_url":"https://avatars.githubusercontent.com/u/4925587?v=3","gravatar_id":"","url":"https://api.github.com/users/barseghyanartur","html_url":"https://github.com/barseghyanartur","followers_url":"https://api.github.com/users/barseghyanartur/followers","following_url":"https://api.github.com/users/barseghyanartur/following{/other_user}","gists_url":"https://api.github.com/users/barseghyanartur/gists{/gist_id}","starred_url":"https://api.github.com/users/barseghyanartur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barseghyanartur/subscriptions","organizations_url":"https://api.github.com/users/barseghyanartur/orgs","repos_url":"https://api.github.com/users/barseghyanartur/repos","events_url":"https://api.github.com/users/barseghyanartur/events{/privacy}","received_events_url":"https://api.github.com/users/barseghyanartur/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-19T15:39:08Z","updated_at":"2015-11-23T10:06:43Z","closed_at":"2015-11-23T09:43:24Z","pull_request":{"url":"https://api.github.com/repos/makinacorpus/django-safedelete/pulls/38","html_url":"https://github.com/makinacorpus/django-safedelete/pull/38","diff_url":"https://github.com/makinacorpus/django-safedelete/pull/38.diff","patch_url":"https://github.com/makinacorpus/django-safedelete/pull/38.patch"},"body":"myapp/models.py\r\n------------------------\r\n\r\n```python\r\n    from django.utils import six, timezone\r\n    from django.db import models\r\n    from django.contrib.auth.models import (\r\n        AbstractBaseUser, PermissionsMixin, BaseUserManager\r\n    )\r\n    from django.core.mail import send_mail\r\n    from django.utils.translation import ugettext_lazy as _\r\n\r\n    from safedelete.models import safedelete_mixin_factory\r\n    from safedelete.utils import SOFT_DELETE\r\n\r\n    class UserManager(BaseUserManager):\r\n        \"\"\"\r\n        User manager.\r\n        \"\"\"\r\n        use_in_migrations = True\r\n\r\n        def _create_user(self, email, password,\r\n                         is_staff, is_superuser, **extra_fields):\r\n            \"\"\"\r\n            Creates and saves a User with the given username, email and password.\r\n            \"\"\"\r\n            now = timezone.now()\r\n            if not email:\r\n                raise ValueError('The given email must be set')\r\n            email = self.normalize_email(email)\r\n            user = self.model(email=email,\r\n                              is_staff=is_staff, is_active=True,\r\n                              is_superuser=is_superuser,\r\n                              date_joined=now, **extra_fields)\r\n            user.set_password(password)\r\n            user.save(using=self._db)\r\n            return user\r\n\r\n        def create_user(self, email=None, password=None, **extra_fields):\r\n            return self._create_user(email, password, False, False,\r\n                                     **extra_fields)\r\n\r\n        def create_superuser(self, email, password, **extra_fields):\r\n            return self._create_user(email, password, True, True,\r\n                                     **extra_fields)\r\n\r\n    # Soft delete - models will be soft-deleted.\r\n    SoftDeleteMixin = safedelete_mixin_factory(SOFT_DELETE,\r\n                                               manager_superclass=UserManager)\r\n\r\n    class User(SoftDeleteMixin, AbstractBaseUser, PermissionsMixin):\r\n        \"\"\"\r\n        An abstract base class implementing a fully featured User model with\r\n        admin-compliant permissions.\r\n\r\n        Username, password and email are required. Other fields are optional.\r\n        \"\"\"\r\n        first_name = models.CharField(_('first name'), max_length=30, null=True,\r\n                                      blank=True)\r\n        last_name = models.CharField(_('last name'), max_length=30, null=True,\r\n                                     blank=True)\r\n        email = models.EmailField(_('email address'), unique=True)\r\n        is_staff = models.BooleanField(_('staff status'), default=False,\r\n            help_text=_('Designates whether the user can log into this admin '\r\n                        'site.'))\r\n        is_active = models.BooleanField(_('active'), default=True,\r\n            help_text=_('Designates whether this user should be treated as '\r\n                        'active. Unselect this instead of deleting accounts.'))\r\n        date_joined = models.DateTimeField(_('date joined'), default=timezone.now)\r\n\r\n        # Additional fields\r\n\r\n        USERNAME_FIELD = 'email'\r\n        REQUIRED_FIELDS = []\r\n\r\n        class Meta:\r\n            app_label = 'myapp'\r\n            verbose_name = _('User')\r\n            verbose_name_plural = _('Users')\r\n\r\n        def get_full_name(self):\r\n            \"\"\"\r\n            Returns the first_name plus the last_name, with a space in between.\r\n            \"\"\"\r\n            full_name = '%s %s' % (self.first_name, self.last_name)\r\n            return full_name.strip()\r\n\r\n        def get_short_name(self):\r\n            \"Returns the short name for the user.\"\r\n            return self.first_name\r\n\r\n        def email_user(self, subject, message, from_email=None, **kwargs):\r\n            \"\"\"\r\n            Sends an email to this User.\r\n            \"\"\"\r\n            send_mail(subject, message, from_email, [self.email], **kwargs)\r\n```\r\nwhy?\r\n-----\r\nWithout the change migrations (./manage.py makemigrations) fail. The traceback:\r\n\r\n    Traceback (most recent call last):\r\n      File \"./manage.py\", line 10, in <module>\r\n        execute_from_command_line(sys.argv)\r\n      File \"/home/user/.virtualenvs/myenv/lib/python3.4/site-packages/django/core/management/__init__.py\", line 338, in execute_from_command_line\r\n        utility.execute()\r\n      File \"/home/user/.virtualenvs/myenv/lib/python3.4/site-packages/django/core/management/__init__.py\", line 330, in execute\r\n        self.fetch_command(subcommand).run_from_argv(self.argv)\r\n      File \"/home/user/.virtualenvs/myenv/lib/python3.4/site-packages/django/core/management/base.py\", line 393, in run_from_argv\r\n        self.execute(*args, **cmd_options)\r\n      File \"/home/user/.virtualenvs/myenv/lib/python3.4/site-packages/raven/contrib/django/management/__init__.py\", line 41, in new_execute\r\n        return original_func(self, *args, **kwargs)\r\n      File \"/home/user/.virtualenvs/myenv/lib/python3.4/site-packages/django/core/management/base.py\", line 444, in execute\r\n        output = self.handle(*args, **options)\r\n      File \"/home/user/.virtualenvs/myenv/lib/python3.4/site-packages/django/core/management/commands/makemigrations.py\", line 99, in handle\r\n        ProjectState.from_apps(apps),\r\n      File \"/home/user/.virtualenvs/myenv/lib/python3.4/site-packages/django/db/migrations/state.py\", line 178, in from_apps\r\n        model_state = ModelState.from_model(model)\r\n      File \"/home/user/.virtualenvs/myenv/lib/python3.4/site-packages/django/db/migrations/state.py\", line 441, in from_model\r\n        reconstruct_manager(model._default_manager)\r\n      File \"/home/user/.virtualenvs/myenv/lib/python3.4/site-packages/django/db/migrations/state.py\", line 425, in reconstruct_manager\r\n        as_manager, manager_path, qs_path, args, kwargs = mgr.deconstruct()\r\n      File \"/home/user/.virtualenvs/myenv/lib/python3.4/site-packages/django/db/models/manager.py\", line 110, in deconstruct\r\n        % (name, module_name)\r\n    ValueError: Could not find manager SafeDeleteManager in safedelete.managers.\r\n    Please note that you need to inherit from managers you dynamically generated with 'from_queryset()'.\r\n"},"comment":{"url":"https://api.github.com/repos/makinacorpus/django-safedelete/issues/comments/158893442","html_url":"https://github.com/makinacorpus/django-safedelete/pull/38#issuecomment-158893442","issue_url":"https://api.github.com/repos/makinacorpus/django-safedelete/issues/38","id":158893442,"user":{"login":"Gagaro","id":3845486,"avatar_url":"https://avatars.githubusercontent.com/u/3845486?v=3","gravatar_id":"","url":"https://api.github.com/users/Gagaro","html_url":"https://github.com/Gagaro","followers_url":"https://api.github.com/users/Gagaro/followers","following_url":"https://api.github.com/users/Gagaro/following{/other_user}","gists_url":"https://api.github.com/users/Gagaro/gists{/gist_id}","starred_url":"https://api.github.com/users/Gagaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gagaro/subscriptions","organizations_url":"https://api.github.com/users/Gagaro/orgs","repos_url":"https://api.github.com/users/Gagaro/repos","events_url":"https://api.github.com/users/Gagaro/events{/privacy}","received_events_url":"https://api.github.com/users/Gagaro/received_events","type":"User","site_admin":false},"created_at":"2015-11-23T10:06:43Z","updated_at":"2015-11-23T10:06:43Z","body":"Released in 0.3.2"}}