Hi, You check an Implementation I did using Django Rest framework over here hope that it will help you. I was using pandas to read the csv records to the model. https://github.com/pmutua/drf_csv_xlsx_file_upload/blob/master/patients/views.py
On Thu, Apr 29, 2021 at 5:23 PM 'Muhammad Asim Khaskheli' via Django developers (Contributions to Django itself) < django-developers@googlegroups.com> wrote: > Hi, > > I wanted to ask how to load csv data into the model. What steps do we have > to follow . > > I have made this function but how exactly to run this code because, python > manage.py loaddata wont work. > > def import_data(): > with open('sample-dataset.csv') as f: > reader = csv.reader(f) > for row in reader: > if row[0] != 'user_id': > _, created = Funnel.objects.get_or_create( > user_id=row[0], > event=row[1], > timestamp=row[2], > session_id=row[3] > ) > > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/ab4f4d9d-87b6-45e4-b490-1d665b1795can%40googlegroups.com > <https://groups.google.com/d/msgid/django-developers/ab4f4d9d-87b6-45e4-b490-1d665b1795can%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAH5spar68VXV51cS0WSeOtGTEsQFke85tJxyTKgpqCZuktJ5vg%40mail.gmail.com.