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.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -