python - Export user data with django in django-admin to CSV -
i need export csv users of database, have more or less clear (https://docs.djangoproject.com/en/dev/howto/outputting-csv/), need select fields exported previously.
is possible, using model, show can select fields exported?
from console, try
>>> django.contrib.auth.models import user >>> open('myfile.csv', 'w') csv: ... user in user.objects.all(): ... d = '%s, %s, %s,\n' % (user.username, user.last_name, user.first_name) ... csv.write(d)
where set d
whichever fields want save.
of course, pain if want several times - it's better idea create custom admin command.