title: Unable to save response data to instance's fields; other data in same block is saved correctly (Django/Celery)
body: <p>I'm running a task to create an account on a third-party service and save relevant data from that service's response to my <code>profile</code> object. The task is running and the data is getting returned correctly but not being properly saved on the object.</p>
  
  <p>Relevant code:</p>
  
  <pre><code>    # payload is generated in helper method. if that was the point of
      # failure, i'd see an error
      result = self.third_party_client.post(self.creation_endpoint, payload)
  
      json_result = result.json()
  
      if json_result.get('Error') != 'SUCCESS':
          # Account Creation Failed. error is handled.
      else:
          # Currently I log this on our staging server to make sure
          # the data's coming back properly; it is returned as expected
          self.logger.error('CoreCard Account Created. Data: {}'.format(json_result))
          profile = user.profile
          profile.account_number = json_result.get('AccountNumber')
          profile.card_number_last_four = int(json_result.get('CardNumber')[12:])
          profile.customer_id = json_result.get('CustomerID')
          profile.account_creation_datetime = datetime.datetime.utcnow()
          profile.save()
  </code></pre>
  
  <p>So if I then query this <code>profile</code> instance, it has the <code>account_creation_datetime</code> value as expected, but the other fields are blank. I've checked the logs and the <code>json_result</code> values are all correct.</p>
  
  <p>Now here's where it's a bit weird. Where I think it's actually failing is the celery task that calls the utility that runs this bit of code. If I run this utility manually, the fields are saved properly. If I run it as part of our normal workflow (called within an async task), the account is created on the third-party service so I know this code is executing, but the <code>profile</code> fields (except for <code>account_creation_datetime</code>) are blank. The task looks like this:</p>
  
  <pre><code>@shared_task(bind=True, max_retries=3)
  def create_account_task(self, guid):
      profile = Profile.objects.get(historical_id=guid)
      profile.account_creation_worker_id = current_task.request.id # Per http://docs.celeryproject.org/en/latest/reference/celery.html#celery.current_task
      profile.save()
  
      # Sanity Check
      if profile.approval_date is not None:
          util = CoreCardUtility()
          util.create_corecard_account(profile.user)
          return True
      return False
  </code></pre>
  
  <p>In this workflow, <code>profile.account_creation_worker_id</code> is <em>also</em> not saved correctly, even if I know the task ran because the account is created on the third-party service.</p>
  
  <p>I'm at a bit of a loss — is there an issue with Celery workers or threading that I'm missing here?</p>
  
  <p>Thank you for your help!</p>