Пример #1
0
def download_ngo_list(request):
    district = request.GET.get('district', None)
    filename = 'ngo_list.csv'
    if district is not None:
        filename = 'ngo_list_{0}.csv'.format(district)
        qs = NGO.objects.filter(district=district).order_by('district', 'name')
    else:
        qs = NGO.objects.all().order_by('district', 'name')
    header_row = [
        'Organisation',
        'Type',
        'Address',
        'Name',
        'Phone',
        'Description',
        'District',
        'Area',
        'Location',
    ]
    body_rows = qs.values_list(
        'organisation',
        'organisation_type',
        'organisation_address',
        'name',
        'phone',
        'description',
        'district',
        'area',
        'location',
    )
    return create_csv_response(filename, header_row, body_rows)
Пример #2
0
def download_ngo_list(request):
    district = request.GET.get("district", None)
    filename = "ngo_list.csv"
    if district is not None:
        filename = "ngo_list_{0}.csv".format(district)
        qs = NGO.objects.filter(district=district).order_by("district", "name")
    else:
        qs = NGO.objects.all().order_by("district", "name")
    header_row = [
        "Organisation",
        "Type",
        "Address",
        "Name",
        "Phone",
        "Description",
        "District",
        "Area",
        "Location",
    ]
    body_rows = qs.values_list(
        "organisation",
        "organisation_type",
        "organisation_address",
        "name",
        "phone",
        "description",
        "district",
        "area",
        "location",
    )
    return create_csv_response(filename, header_row, body_rows)