title: How to use previously defined methods (funcs) in "export" function in Python/Django?
body: <p>Been updating a Python/Django project, and I know pretty much nothing about it, whatsoever.</p>
  
  <p>Currently I have been trying to export a current view (change list) to CSV. The columns are printed fine, all the methods (functions) are displaying all info as they should/expected.</p>
  
  <p>When hitting "Export" link the hardcore starts, and it's been up for weeks now.</p>
  
  <p>Finally something started to show in my .csv file, yet still I cannot print out methods like <code>how_many</code> or <code>postal_code</code> inside the loop <strong><code>for elem in csv_elements:</code></strong></p>
  
  <p>Below is a partially printed class that takes care of displaying columns on the screen and then export them to the <code>.csv</code> file. I didn't include all of it, just parts I personally think are important to show (I may be very wrong about this of course). Basically everything down to <code>export_this_list</code> works just fine.</p>
  
  <p>What syntax should I use to be able to re-use already defined functions (methods) inside the last function (method)?</p>
  
  <pre><code>class EnrolmentAdmin(TrainingAdminMixin, admin.ModelAdmin):
      """EnrolmentAdmin is used for registering Enrolment model."""
  
      form = EnrolmentForm
          .
            .
      list_display = ('date', 'training', 'postal_code', 'how_many')
          .
            .
      def postal_code(self, obj):
          return obj.invoice_data['postal_code']
  
      def how_many(self, obj):
          return obj.total_participants
  
      how_many.short_description = "How Many Persons"
          .
            .
      def export_this_list(self, request):
          """Generates participants list in Excel sheet."""
          filename = 'Orders.csv'
          csv_elements = Enrolment.objects.all()
  
          if not csv_elements:
              response = HttpResponseRedirect(
                  reverse('admin:xxxxxx_training_change', args=[object_id]))
              msg = _('There are no orders yet.')
              messages.error(request, msg)
          else:
              response = HttpResponse(content_type='text/csv')
              response[
                  'Content-Disposition'] = 'attachment; filename="{}"'.format(
                  filename)
              #fieldnames = ['Date', 'Training', 'Postal code', 'How many']
              fieldnames = ['How many']
  
              sheet = csv.DictWriter(
                  response, fieldnames=fieldnames, delimiter=';')
              sheet.writeheader()
  
              for elem in csv_elements:
                  sheet.writerow({
                      'How many': self.how_many
                  })
  
          return response
  </code></pre>