@login_required()
def generate_csv(request):
file = 'inventory.csv'
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="%s"' % file
equipment = Equipment.objects.filter(is_active=True)
writer = csv.writer(response, delimiter=';')
for eq in equipment:
writer.writerow([eq.field_1, eq.field_2, ...])
return response