title: "response": "strptime() argument 1 must be str, not datetime.datetime" django datetime format problem
body: <p>In Django, I have written a delete method in which I am getting some requests of data from the delete API
  The requested data is</p>
  <pre><code>[
      {
        &quot;acerage&quot;: 1,
        &quot;batch_health&quot;: null,
        &quot;actual_produce&quot;: null,
        &quot;actual_yield_per_acre&quot;: null,
        &quot;batch_id&quot;: 2583,
        &quot;batch_status&quot;: &quot;running&quot;,
        &quot;commodity_id&quot;: 6,
        &quot;commodity_variety_id&quot;: 20,
        &quot;current_gdd&quot;: null,
        &quot;current_pdd&quot;: null,
        &quot;expected_delivery_date&quot;: &quot;2022-02-15T18:30:00.000Z&quot;,
        &quot;expected_produce&quot;: null,
        &quot;farm_id&quot;: &quot;1806&quot;,
        &quot;historic_gdd&quot;: null,
        &quot;historic_pdd&quot;: null,
        &quot;historical_yield_per_acre&quot;: null,
        &quot;sop_adherence&quot;: null,
        &quot;stage&quot;: &quot;germination&quot;,
        &quot;start_date&quot;: &quot;2022-02-06T18:30:00.000Z&quot;
      }
  ]
  </code></pre>
  <p>I am deleting a row in my DB based on batch_id by using the delete method
  and the delete method looks like</p>
  <pre><code>
      def destroy(self, request, *args, **kwargs):
          &quot;&quot;&quot;
              This function is used to destroy batch object
          &quot;&quot;&quot;
          try:
              instance = self.get_object()
              instance.batch_status = 'aborted'
              instance.save()
              solr_delta_import()
          except Exception as e:
              return Response({&quot;response&quot;: str(e)}, status=status.HTTP_400_BAD_REQUEST)
          return Response({&quot;response&quot;: &quot;deleted successfully&quot;}, status=status.HTTP_200_OK)
  </code></pre>
  <p>and the row gets deleted when we run this function</p>
  <p>My problem here is the requested data values start_time and expected_delivery_date
  is coming in the string format
  but due to some calculations in my model file, I am converting that string to a DateTime format which looks like this</p>
  <p>the model file looks like</p>
  <pre><code>    def update_batch_median_health(self):
          if self.start_date and self.expected_delivery_date:
              if self.id:
                  start_date = datetime.strptime(self.start_date, '%Y-%m-%dT%H:%M:%SZ')
                  expected_delivery_date = datetime.strptime(self.expected_delivery_date, '%Y-%m-%dT%H:%M:%SZ')
              else:
                  start_date = datetime.combine(self.start_date, datetime.min.time())
                  expected_delivery_date = datetime.combine(self.expected_delivery_date, datetime.min.time())
              end_date = min([expected_delivery_date, datetime.today()]) - relativedelta(hours=5, minutes=30)
              hours_diff = int((((end_date - start_date).total_seconds()) / 3600 / 2))
              median_date = start_date + relativedelta(hours=hours_diff)
              
              try:
                  median_crop_health = self.history.as_of(median_date).crop_health
              except:
                  median_crop_health = self.batch_health
              return median_crop_health
          else:
              return None
  
      def update_batch_name(self):
          batch_name = &quot;({}) {}&quot;.format(self.id, self.commodity_name)
          if self.start_date:
              if self.id:
                  start_date = self.start_date.split(&quot;T&quot;)
                  batch_name += &quot; | {}&quot;.format(start_date[0])
              else:
                  batch_name += &quot; | {}&quot;.format(self.start_date.strftime('%Y-%m-%d'))
          return batch_name
  
  </code></pre>
  <p>Now the start_date and expected_delivery_date format is DateTime</p>
  <pre><code>start_date = 2022-02-06 18:30:00+00:00
  expected_delivery_date = 2022-02-15 18:30:00+00:00
  
  </code></pre>
  <p>Now this when the instance is getting the wrong response due to the wrong start_date and expected_delivery_date format the delete function is not giving the proper response</p>
  <p>The error is</p>
  <pre><code>&quot;response&quot;: &quot;strptime() argument 1 must be str, not datetime.datetime&quot;
  }
  
  Bad Request: /api/v1/batch/2583/
  [19/Feb/2022 08:01:49] &quot;DELETE /api/v1/batch/2583/ HTTP/1.1&quot; 400 71
  
  </code></pre>
  <p>How can convert again that both columns back to a string for and save that request_date and can run the delete function?</p>