Skip to content

Instantly share code, notes, and snippets.

@ibrahimsha23
Created May 28, 2021 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibrahimsha23/8559180ac010870ac2c10c15959c60df to your computer and use it in GitHub Desktop.
Save ibrahimsha23/8559180ac010870ac2c10c15959c60df to your computer and use it in GitHub Desktop.
Easy way to convert django model objects to csv formats

Steps to download the django model obj to csv file

Installation

pip install django-pandas

app.py

from django_pandas.io import read_frame
from django.contrib.auth.models import User 


user_ob = User.objects.all()
df = read_frame(user_obj)
df.to_csv('raw_data.csv', index=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment