import csv

from django.contrib import admin
from django.http import HttpResponse
from django.utils.translation import ugettext_lazy as _

from . import app_settings
from .models import Project, ProjectAdmin, PledgeInlineAdmin
from .utils import get_backer_model, use_default_backer_model

def export_as_csv(modeladmin, request, queryset):
    opts = modeladmin.model._meta
    response = HttpResponse(mimetype='text/csv')
    response['Content-Disposition'] = 'attachment; filename=export.csv'
    writer = csv.writer(response)
    field_names = modeladmin.list_display
    writer.writerow(field_names)
    for obj in queryset:
        writer.writerow([
            unicode(getattr(obj, field)).encode('utf-8')
            for field in field_names])
    return response

export_as_csv.short_description = _('Export as csv')


class DefaultBackerAdmin(admin.ModelAdmin):
    list_display = ('first_name', 'last_name', 'email')
    search_fields = ('first_name', 'last_name', 'email')
    raw_id_fields = ['user']
    inlines = [PledgeInlineAdmin]
    actions = [export_as_csv]

if use_default_backer_model():
    BackerModel = get_backer_model()
    admin.site.register(BackerModel, DefaultBackerAdmin)

admin.site.register(Project, ProjectAdmin)

@@ -938,24 +938,25 @@
 _fields = ('
+_
 first_name',
@@ -949,32 +949,33 @@
 '_first_name', '
+_
 last_name', 'ema
@@ -963,32 +963,66 @@
  '_last_name', '
+_email', 'user__username', 'user__
 email')%0A    raw_

fix backer search