Skip to content

Instantly share code, notes, and snippets.

@agaerig
Created January 15, 2013 18:15
Show Gist options
  • Save agaerig/4540654 to your computer and use it in GitHub Desktop.
Save agaerig/4540654 to your computer and use it in GitHub Desktop.
class Command(NoArgsCommand):
def handle_noargs(self, **options):
users = User.objects.all()
response = HttpResponse(mimetype='text/csv')
response['Content-Disposition'] = 'attachment; filename=incomplete.csv'
writer = csv.writer(response)
for u in users:
if not u.first_name or not u.last_name:
writer.writerow([u.id,
u.username,
u.first_name,
u.last_name,
u.email])
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment