'Serialize a queryset.'

def serialize(self, queryset, **options):

    self.options = options
    self.stream = options.pop('stream', StringIO())
    self.selected_fields = options.pop('fields', None)
    self.use_natural_keys = options.pop('use_natural_keys', False)
    dest_version = options.pop('dest_version')
    self.start_serialization()
    self.first = True
    for obj in queryset:
        v_diff = version_diff(dest_version, getattr(obj, 'minversion', None))
        if ((v_diff is not None) and (v_diff < 0)):
            continue
        self.start_object(obj)
        concrete_model = obj._meta.concrete_model
        for field in concrete_model._meta.local_fields:
            v_diff = version_diff(dest_version, getattr(field, 'minversion', None))
            if (field.serialize and ((v_diff is None) or (v_diff >= 0))):
                if (field.rel is None):
                    if ((self.selected_fields is None) or (field.attname in self.selected_fields)):
                        self.handle_field(obj, field)
                elif ((self.selected_fields is None) or (field.attname[:(-3)] in self.selected_fields)):
                    self.handle_fk_field(obj, field)
        for field in concrete_model._meta.many_to_many:
            v_diff = version_diff(dest_version, getattr(field, 'minversion', None))
            if (field.serialize and ((v_diff >= 0) or (v_diff is None))):
                if ((self.selected_fields is None) or (field.attname in self.selected_fields)):
                    self.handle_m2m_field(obj, field)
        self.end_object(obj)
        self.first = False
    self.end_serialization()
    return self.getvalue()
