title: Create object with serializer Django (DRF)
body: <p>I'm trying to create an object in my view using a serializer.
  However I'm having an annoying issue with one of my objects:</p>
  <p>This is how I create the Object:</p>
  <pre class="lang-py prettyprint-override"><code>editObject = Question_edit(
      question=question,
      description='CREATE Question: %s' % question.text,
      editor=user,
      notes=question.notes
  )
  print(editObject)      # return 'Question_edit object (None)'
  
  serializer = Question_editSerializer(editObject)
  json = JSONRenderer().render(serializer.data)
  stream = io.BytesIO(json)
  data = JSONParser().parse(stream)
  serializer = Question_editSerializer(data=data)
  serializer.is_valid(raise_exception=True)
  serializer.save()
  </code></pre>
  <p>This is my <code>Question_editSerializer</code>:</p>
  <pre class="lang-py prettyprint-override"><code>class Question_editSerializer(serializers.ModelSerializer):
      time_since_edit = serializers.SerializerMethodField()
  
      class Meta:
          model = Question_edit
          fields = &quot;__all__&quot;
  
      def get_time_since_edit(self, object):
          date_edit = object.date
          time_delta = timesince(date_edit, timezone.now())
          return time_delta
  
      def create(self, validated_data):
          return Question_edit.objects.create(**validated_data)
  </code></pre>
  <p>And my <code>Question_edit</code> model:</p>
  <pre class="lang-py prettyprint-override"><code>class Question_edit(models.Model):
      date = models.DateTimeField(auto_now_add=True)
      question = models.ForeignKey(Question, on_delete=models.CASCADE)
      description = models.TextField(max_length=500)
      editor = models.ForeignKey(
          CustomUser, on_delete=models.SET_NULL, null=True)
      notes = models.TextField(max_length=500, blank=True, null=True)
  </code></pre>
  <p>As a result of trying to create the object using the serializer in the first piece of code above, I get this error:</p>
  <pre><code>  File &quot;/foodbook24-api/questions/api/serializers.py&quot;, line 44, in get_time_since_edit
      time_delta = timesince(date_edit, timezone.now())
    File &quot;/usr/local/lib/python3.8/site-packages/django/utils/timesince.py&quot;, line 49, in timesince
      d = datetime.datetime(d.year, d.month, d.day)
  
  Exception Type: AttributeError at /api/questionnaires/
  Exception Value: 'NoneType' object has no attribute 'year'
  </code></pre>
  <p><strong>Complete Traceback:</strong></p>
  <pre><code>Environment:
  
  
  Request Method: POST
  Request URL: http://localhost:8000/api/questionnaires/
  
  Django Version: 3.1.3
  Python Version: 3.8.6
  Installed Applications:
  ['django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'django.contrib.sites',
   'rest_framework',
   'rest_framework.authtoken',
   'drfpasswordless',
   'allauth',
   'allauth.account',
   'allauth.socialaccount',
   'rest_auth',
   'rest_auth.registration',
   'django_filters',
   'corsheaders',
   'surveys',
   'questionnaire',
   'questions',
   'users',
   'foods',
   'utilities']
  Installed Middleware:
  ['django.middleware.security.SecurityMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'corsheaders.middleware.CorsMiddleware',
   'django.middleware.common.CommonMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'django.middleware.clickjacking.XFrameOptionsMiddleware']
  
  
  
  Traceback (most recent call last):
    File &quot;/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py&quot;, line 47, in inner
      response = get_response(request)
    File &quot;/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py&quot;, line 179, in _get_response
      response = wrapped_callback(request, *callback_args, **callback_kwargs)
    File &quot;/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py&quot;, line 54, in wrapped_view
      return view_func(*args, **kwargs)
    File &quot;/usr/local/lib/python3.8/site-packages/django/views/generic/base.py&quot;, line 70, in view
      return self.dispatch(request, *args, **kwargs)
    File &quot;/usr/local/lib/python3.8/site-packages/rest_framework/views.py&quot;, line 509, in dispatch
      response = self.handle_exception(exc)
    File &quot;/usr/local/lib/python3.8/site-packages/rest_framework/views.py&quot;, line 469, in handle_exception
      self.raise_uncaught_exception(exc)
    File &quot;/usr/local/lib/python3.8/site-packages/rest_framework/views.py&quot;, line 480, in raise_uncaught_exception
      raise exc
    File &quot;/usr/local/lib/python3.8/site-packages/rest_framework/views.py&quot;, line 506, in dispatch
      response = handler(request, *args, **kwargs)
    File &quot;/usr/local/lib/python3.8/site-packages/rest_framework/generics.py&quot;, line 242, in post
      return self.create(request, *args, **kwargs)
    File &quot;/foodbook24-api/questionnaire/api/views.py&quot;, line 184, in create
      return self.elaborateClientPOSTRequest(request)
    File &quot;/foodbook24-api/questionnaire/api/views.py&quot;, line 114, in elaborateClientPOSTRequest
      self.create_question_edit_record(questionObject, request)
    File &quot;/foodbook24-api/questionnaire/api/views.py&quot;, line 85, in create_question_edit_record
      json = JSONRenderer().render(serializer.data)
    File &quot;/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py&quot;, line 548, in data
      ret = super().data
    File &quot;/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py&quot;, line 246, in data
      self._data = self.to_representation(self.instance)
    File &quot;/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py&quot;, line 515, in to_representation
      ret[field.field_name] = field.to_representation(attribute)
    File &quot;/usr/local/lib/python3.8/site-packages/rest_framework/fields.py&quot;, line 1870, in to_representation
      return method(value)
    File &quot;/foodbook24-api/questions/api/serializers.py&quot;, line 44, in get_time_since_edit
      time_delta = timesince(date_edit, timezone.now())
    File &quot;/usr/local/lib/python3.8/site-packages/django/utils/timesince.py&quot;, line 49, in timesince
      d = datetime.datetime(d.year, d.month, d.day)
  
  Exception Type: AttributeError at /api/questionnaires/
  Exception Value: 'NoneType' object has no attribute 'year'
  </code></pre>
  <p>What am I missing here?</p>