title: How to add a method to Django class to convert to dictionary
body: <p>I am making a reporting tool for some SW testing...</p>
  <p>I have the following model in my models.py file</p>
  <pre><code>class triage_notes(models.Model):
      stack_name = models.CharField(
          max_length=30
      )
      
      build_number = models.IntegerField(    )
      
      fails = models.IntegerField()
  
      jira_ticket = models.CharField(
          max_length=100
      )
      
      notes = models.TextField()
      
      bug_type = models.CharField(
          max_length=50
      )
      def as_dict(self, *args, **kwargs):
          return {
              &quot;id&quot;:self.id,
              &quot;build_number&quot;: self.build_number,
              &quot;fails&quot;: self.fails,
              &quot;jira_ticket&quot;: self.jira_ticket,
              &quot;notes&quot;: self.notes,
              &quot;bug_type&quot;: self.bug_type
          }
  </code></pre>
  <p>As you can imagine, the goal is to be able to use this method in the query call in order to present my query as a dictionary...</p>
  <p>In my view I am attempting to use this method</p>
  <pre><code>def index_view(request):
      context = triage_notes.objects.as_dict()
      print(context)
      return render(request, 'index.html', context)
  
  </code></pre>
  <p>But I am getting the following error</p>
  <pre><code>TypeError: as_dict() missing 1 required positional argument: 'self'
  </code></pre>
  <p>I would love to understand this process better as being able to implement custom methods for my models would be a great tool in the future.</p>
  <p>Any recommendations would be greatly appreciated! :)</p>