Beispiel #1
0
 def test_csv_user_export(self):
     """
     Ensure export model returns a csv file
     """
     c = Client()
     request = c.get(reverse('index_view'))
     response = export_via_model(User,
                                 request,
                                 User.objects.all(),
                                 exclude=['password'])
     self.assertEqual(response['Content-Type'], 'text/csv')
Beispiel #2
0
    def test_csv_user_export(self):
        """
        Ensure export model returns a csv file
        """
        c = Client()

        request = c.get(reverse('index_view'))

        response = export_via_model(User, request, User.objects.all(), exclude=['password'])

        self.assertEqual(response['Content-Type'], 'text/csv')
Beispiel #3
0
    def export_as_csv(modeladmin, request, queryset):
        """
        Generic csv export admin action.
        based on http://djangosnippets.org/snippets/1697/
        queryset is an iterable returning an object
        with attributes or no-arg callables matching the field names
        """
        if query_factory:
            queryset = query_factory(queryset)

        return export_via_model(modeladmin.model, request, queryset, fields, exclude)
Beispiel #4
0
    def export_as_csv(modeladmin, request, queryset):
        """
        Generic csv export admin action.
        based on http://djangosnippets.org/snippets/1697/
        queryset is an iterable returning an object
        with attributes or no-arg callables matching the field names
        """
        if query_factory:
            queryset = query_factory(queryset)

        return export_via_model(modeladmin.model, request, queryset, fields,
                                exclude)