Django Import CSV into Model

preview_player
Показать описание
In this django tutorial we go through one of may ways to import data from an CSV file into an existing django model.

Code repository:

🐱‍🏍Would you like to SUPPORT US FURTHER so that we can make even more great content - Please consider joining our members community.

👍SUBSCRIBE to get more free tutorials, courses and code snippets!
Рекомендации по теме
Комментарии
Автор

thank you for the tutorial! If anyone has trouble with the ordering of columns after you've imported the csv into the model's database, you could reorder the columns in your csv the exact same way the columns are ordered in the empty database. It might take a bit of time, but it definitely works.

rxlvnd
Автор

This is helping me a lot! Thank you so much :)

DaisyRahman
Автор

That's a different approach, I like it. That's great tutorial.

salahdz
Автор

at 14:34 when you check the data, on line 11099 there is a date that is improperly formatted. I wonder if it made it in the database. That is why I always set filter in Excel and quickly loop through the drop down to see if all dates are set inside years, or if there are some values stored as text or otherwise. Alternatively you can create 3 additional columns and run functions: year(date cell), month(date cell), day(date cell) and in the fourth column recreate your date with certainty they will all be equally formatted. Of course, afterwards you delete all additional columns and copy the forth one in the date column.

aleksandarradovic
Автор

great video! quick question, when i want to update existing objects via import, and my csv has blank cells for a column, it replaces the data in my objects with that blank empty string, how do i stop django import from doing this?

normanluismadrid
Автор

If you can teach your fans (me included) how to set up a button in the admin site, let an admin upload a csv/excel file and then insert the data into database, that would be a giant move. People who are real web developers need to do this for their clients.

Troglodyte
Автор

hi what if the column names are having spaces instead of '_'(underscore) in the csv file? how should we represent the models.?

satishkurakula
Автор

hi thank you for sharinbg but I am just wondering how do you make that autoifill at time 6:56 for all the coulmn in your class Book? since I trying the same methods I can not do that

iufdkij
Автор

can you guide me with handle csv file upload and should be save into model and that csv may contain large data... thanks in advance

rakeshroy
Автор

This is great thank you! New subscriber. Be nice for users with permissions to drag n drop a csv and dynamically update the database and site page with inventory and totals, as opposed to individually adding inventory items one by one.

yasayah
Автор

Thank you. This is very useful.. How can we import a large data set quickly like you did using Django itself (extending a button for user) rather than doing it using the shell from backend.

ayeshrodrigo
Автор

Best presented tutorial I could find on this topic. Thanks. Now just need to figure out how to automate this!? Can anyone point me to any resource that will automate the import?

jamesmoulds
Автор

This was a really great video. How would you do this if you had a remote PostgreSQL DB as opposed to sqlite?

franciskalonjimbuyamba
Автор

Thanks for the video! pretty nice info. How would you go about adding the data from a pandas dataframe to the DB?

cristobaljvp
Автор

Could you please also post a video how to export Django database models to Excel template with some formatting via the Django admin?

dinuzakbayev
Автор

I have executed .import something.csv library_book but I didn’t get any error but data didn’t get inserted. Is there any reason why?

sahithimallineni
Автор

How can we import notepad file in database

mohittamba
Автор

I would use pandas to read the csv, save u time n give u extra tools. Good video

baloney_sandwich
Автор

Thanks ! but sir how can i do this using postgresql ? i can't find reasorses could help with that .

musicvstime
Автор

running sqlite3.exe command giving me error like 'not recognized', what to do?

whitehacker