Commit a0aa469e authored by Jean-Baptiste's avatar Jean-Baptiste

update: use settings.AUTH_USER_MODEL

parent 5b5ad3bb
Pipeline #3158 failed with stage
in 1 minute and 22 seconds
import factory
from django.contrib.auth.models import User
from django.conf import settings
from django.db.models.signals import post_save
@factory.django.mute_signals(post_save)
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
model = User
model = settings.AUTH_USER_MODEL
username = factory.Faker('user_name')
first_name = factory.Faker('first_name')
......
from django.apps import apps
from django.conf import settings
from django.conf.urls import url, include
from django.contrib.auth.models import User
from django.core.exceptions import FieldDoesNotExist
from django.core.urlresolvers import get_resolver
from django.db.utils import OperationalError, ProgrammingError
......@@ -120,7 +119,7 @@ class LDPViewSet(LDPViewSetGenerator):
return type(LDPSerializer)(model_name + 'Serializer', (LDPSerializer,), {'Meta': meta_class})
def perform_create(self, serializer, **kwargs):
if hasattr(self.model._meta, 'auto_author') and isinstance(self.request.user, User):
if hasattr(self.model._meta, 'auto_author') and isinstance(self.request.user, settings.AUTH_USER_MODEL):
kwargs[self.model._meta.auto_author] = self.request.user
serializer.save(**kwargs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment