Please tell me how using Django REST framework to get the owner of the model? There is a User model:
class User(AbstractBaseUser, PermissionsMixin):
a model Seeker associated with the User:
class Seeker(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL)
is the model associated with Seeker:
class Education(CreatedModified): seeker = models.ForeignKey(Seeker)
when creating a serializer class EducationSerializerCreate I need to get seeker field associated with the current user session, and to substitute it by default in the serializable model
now the code is like this:
class EducationSerializerCreate(serializers.ModelSerializer): user = serializers.HiddenField(default=serializers.CurrentUserDefault()) seeker = Seeker.objects.filter(user=user) class Meta: model = Education fields = '__all__'
accordingly, Python complains:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'HiddenField'
tell me how to do?