title: TypeError: 'method' object is not subscriptable Python/django
body: <p>I have a test case that is returning the following error.</p>
  
  <p><strong>Traceback</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/lib/python3.7/unittest/mock.py", line 1255, in patched
      return func(*args, **keywargs)
    File "/dir/to/project/Anwser/qanda/tests.py", line 29, in test_elasticsearch_upsert_on_save
      q.save()
    File "/dir/to/project/Anwser/qanda/models.py", line 40, in save
      elasticsearch.upsert(self)
    File "/dir/to/project/Anwser/qanda/service/elasticsearch.py", line 54, in upsert
      doc_type = question_dict['_type']
  TypeError: 'method' object is not subscriptable
  </code></pre>
  
  <p>Here is the function that lives inside <code>elasticsearch.py</code></p>
  
  <pre><code>def upsert(question_model):
      client = get_client()
      question_dict = question_model.as_elastic_search_dict
      doc_type = question_dict['_type']
      del question_dict['_id']
      del question_dict['_type']
      response = client.update(
          settings.ES_IDENX,
          question_dict,
          id=question_model.id,
          body={
              'doc': doc_type,
              'doc_as_upsert': True,
          }
      )
      return response
  </code></pre>
  
  <p>As i have read other threads about similar issues, i came to a conclusion that the problem relies in <strong>__getItem(self)__</strong> of the object that is calling the function.
  Since the function should return a dictionary, it returns a method instead.</p>
  
  <p>Here is the function inside of model.</p>
  
  <pre><code>def as_elastic_search_dict(self):
          return {
              '_id': self.id,
              '_type': 'doc',
              'text': '{}\n{}'.format(self.title, self.question),
              'question_body': self.question,
              'title': self.title,
              'id': self.id,
              'created': self.created,
          }
  </code></pre>
  
  <p><strong>TestCase:</strong></p>
  
  <pre><code>class QuestionSaveTestCase(TestCase):
      """
          Testing Question.save()
      """
  
      @patch('qanda.service.elasticsearch.Elasticsearch')
      def test_elasticsearch_upsert_on_save(self, ElasticSearchMock):
          user = User.objects.create(
              username='unittest',
              password='unittest'
          )
          question_title = 'Unit test'
          question_body = 'Some unit test'
          q = Question(title=question_title,
                       question=question_body,
                       user=user)
          q.save()
  
          self.assertIsNotNone(q.id)
          self.assertTrue(ElasticSearchMock.called)
          mock_client = ElasticSearchMock.return_value
          mock_client.update.assert_called_once_with(
              settings.ES_IDENX,
              id=q.id,
              body={
                  'doc': {
                      '_type': 'doc',
                      'text': '{}\n{}'.format(question_title, question_body),
                      'question_body': question_body,
                      'title': question_title,
                      'id': q.id,
                      'created': q.created,
                  },
                  'doc_as_upsert': True,
              }
          )
  </code></pre>
  
  <p>What are all the possible usecase's that can be used to solve this problem? If my understanding was correct, then i should override <strong>__getItem(self)__</strong> to return the dictionary. If that is correct how should i implement <strong>__getItem(self)__</strong> and if it will be configured to return the dictionary, how will it affect the object lifecycle in total?</p>