Django Import CSV into Model

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 89

  • @rxlvnd3397
    @rxlvnd3397 4 месяца назад

    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.

  • @Troglodyte2021
    @Troglodyte2021 3 года назад +7

    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.

    • @veryacademy
      @veryacademy  3 года назад +3

      Sure we can do this 👍

    • @hafeezpp
      @hafeezpp 3 года назад +1

      Use django-excel library 👍

    • @g.6013
      @g.6013 3 года назад +5

      use django import-export super easy and usefull

  • @salahdz2834
    @salahdz2834 3 года назад +2

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

    • @veryacademy
      @veryacademy  3 года назад

      Thanks - its all situational. 👍

  • @baloney_sandwich
    @baloney_sandwich Год назад +1

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

  • @DaisyRahman
    @DaisyRahman Год назад

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

  • @jamesmoulds6960
    @jamesmoulds6960 3 года назад +2

    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?

  • @franciskalonjimbuyamba5215
    @franciskalonjimbuyamba5215 2 года назад +2

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

    • @veryacademy
      @veryacademy  2 года назад +1

      Have you tried hooking up a Postgres db?

    • @samueltaylor2757
      @samueltaylor2757 2 года назад +1

      Hi! I did this using a postgres client link DBeaver which is really intuitive to use

  • @mounirben9370
    @mounirben9370 3 года назад +1

    Excellent tutorial!

  • @ayeshrodrigo2197
    @ayeshrodrigo2197 3 года назад +3

    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.

    • @veryacademy
      @veryacademy  3 года назад

      Hope I answered this one in the other tutorial.

    • @g.6013
      @g.6013 3 года назад

      @@veryacademy can you tellme where is this tutorial you are talking about thanks for your great tutorial

  • @rajarshimazumder2350
    @rajarshimazumder2350 Год назад

    very much helpful thanku

  • @KlausBentes
    @KlausBentes 2 года назад

    Huge help! Thank you very much! 🙏

  • @leo44370
    @leo44370 3 года назад +1

    Late night weekend updates. Working hard 👍

    • @veryacademy
      @veryacademy  3 года назад

      Mate, this is just a bad habit.

  • @gunahawk6893
    @gunahawk6893 2 года назад

    Made by day by finding your channel

  • @normanluismadrid422
    @normanluismadrid422 2 года назад +1

    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?

  • @owningglory39
    @owningglory39 Год назад

    Thank you

  • @cristobaljvp
    @cristobaljvp 3 года назад +2

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

    • @veryacademy
      @veryacademy  3 года назад

      You can do - its all situational - I wouldn't bring in pandas just for that - if I was working panda anyway - then why not, its an option. Any its all very situational.

    • @venkyslarky8817
      @venkyslarky8817 2 года назад

      @@veryacademy Hello man. Thanks for awesome info. Can you make a separate tutorial or give some reference for the same of using management command with pandas.

  • @dinuzakbayev4349
    @dinuzakbayev4349 2 года назад

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

  • @Anilkumar-lk2uw
    @Anilkumar-lk2uw Год назад

    Thanks bro

  • @musicvstime9559
    @musicvstime9559 2 года назад +1

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

    • @veryacademy
      @veryacademy  2 года назад +1

      Setup django in the settings with Postgres and then it should be the same process?

  • @aleksandarradovic2960
    @aleksandarradovic2960 3 года назад +1

    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.

  • @westporthardware5179
    @westporthardware5179 3 года назад +2

    Hi,
    I m using my data and followed step by step , I encountering error of data type mismatch , even I have deleted data and leave only 1 Colin , still doesn’t work

    • @veryacademy
      @veryacademy  3 года назад

      Hi, did you fix it. Lets make sure that your database data types are correct and you have lined up the fields with the correct headings of the CSV file

    • @westporthardware5179
      @westporthardware5179 3 года назад

      @@veryacademy i managed to fix that. Quick question, if the data uploaded everyday , do we need to clean the data everytime or there is a quick workaround ?

  • @saidhofiani2670
    @saidhofiani2670 Год назад

    When I put the book model in the settings it says ""ModuleNotFoundError: No module named"

  • @whitehacker6171
    @whitehacker6171 10 месяцев назад

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

  • @yasayah7289
    @yasayah7289 2 года назад +1

    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.

  • @valeriiastartseva1612
    @valeriiastartseva1612 2 года назад +1

    hi! how to cancel import csv file to table? if i import wrong file

    • @veryacademy
      @veryacademy  2 года назад

      You don't cancel unfortunately, you revert to the backup you made before you tried to import the csv file

  • @psk9301
    @psk9301 3 года назад +1

    You are best

  • @Yyen-p2m
    @Yyen-p2m Год назад

    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

  • @rakeshroy7118
    @rakeshroy7118 2 года назад

    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

  • @faridsa1084
    @faridsa1084 3 года назад +1

    awesome

  • @sahithimallineni5653
    @sahithimallineni5653 2 года назад

    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?

  • @eesakamaldien1917
    @eesakamaldien1917 2 года назад +1

    hi what if one of the models had a foreign key? then how would this be applied?

    • @saif9170
      @saif9170 2 года назад

      Do you find solutions of it? Please share with me!

    • @eesakamaldien1917
      @eesakamaldien1917 2 года назад +1

      @@saif9170 yes I will share link later to answer

    • @saif9170
      @saif9170 2 года назад

      @@eesakamaldien1917 Please share !!

    • @eesakamaldien1917
      @eesakamaldien1917 2 года назад

      @@saif9170 what is your Facebook I will first need to know what you trying

  • @satishkurakula
    @satishkurakula 2 года назад

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

  • @zakchips
    @zakchips 3 года назад

    Great.Thx.

  • @dennohnjogu4028
    @dennohnjogu4028 2 года назад +1

    how would one handle relationships?

    • @veryacademy
      @veryacademy  2 года назад +1

      Be the best you can, make sure they have lots of money and get married as soon as possible

    • @dennohnjogu4028
      @dennohnjogu4028 2 года назад

      @@veryacademy hahaha..you know what i meant

  • @atlasbulut4968
    @atlasbulut4968 3 года назад +1

    This is great but I would like to do it on admin panel

    • @veryacademy
      @veryacademy  3 года назад +1

      Ta da...
      ruclips.net/video/BLxCnD5-Uvc/видео.html
      Its the next tutorial 👍

  • @bayankabbani3722
    @bayankabbani3722 3 года назад +1

    thanks

  • @dudepowpow
    @dudepowpow Год назад +1

    Why would you choose to limit the video audience scope by proceeding with an import option only available to Windows users?

    • @veryacademy
      @veryacademy  Год назад

      The only limits are ones that you have defined. Apologies if this was a rhetorical question.

    • @jordib.4683
      @jordib.4683 Год назад

      This tutorial doesn't work on Mac?

  • @hamidmojarrad
    @hamidmojarrad Год назад

    I really expected to see you imported the csv file into sqlite using Django codes not the command line

  • @hassanelabdallah5013
    @hassanelabdallah5013 3 года назад

    Hello. Can you please explain annotate,alias,union and aggregate ?

    • @veryacademy
      @veryacademy  3 года назад +1

      No problem - I have done union - I think I planned aggregate tomorrow

  • @ashishthaakur45
    @ashishthaakur45 3 года назад

    Good one

  • @babycool5866
    @babycool5866 3 года назад +1

    Sir, it is showing datatype mismatch what can i do pls tell me

    • @veryacademy
      @veryacademy  3 года назад

      You need to check your data in the csv matches the model data types

  • @rangabharath4253
    @rangabharath4253 3 года назад

    Awesome

  • @mohittamba2709
    @mohittamba2709 3 года назад

    How can we import notepad file in database

  • @datafintechsolutions
    @datafintechsolutions Год назад

    Valeu!

  • @adr3wid
    @adr3wid 2 года назад

    Title is misleading. It should read be "how to import CSV into SQLlite". There are a number of databases Django could be utilising. This is simply interfacing with the database, not making a ORM migration command

  • @mukundapurtourandtravelspr6738
    @mukundapurtourandtravelspr6738 3 года назад

    whenever i try to do this its showing:
    INSERT failed: attempt to write a readonly database

    • @veryacademy
      @veryacademy  3 года назад +1

      Are you running Linux - check the file permission on the database - assuming you are using SQLite?

  • @prakashkombala
    @prakashkombala 2 года назад

    Any one help me to import Json data to django model ?

  • @anilkumar-ug3yd
    @anilkumar-ug3yd 2 года назад +1

    enitire purpose of building a model to uploaddata is ignored

    • @veryacademy
      @veryacademy  2 года назад

      Thanks Anil glad to have helped.

  • @jizong234
    @jizong234 3 года назад

    super claire

  • @gamingland2074
    @gamingland2074 2 года назад +2

    no offense but this tutorail has nothing to do with django , it import CSV file into sqllite3 not Django Import CSV into Model

    • @veryacademy
      @veryacademy  2 года назад

      No offence taken, give me a suitable title and I will replace it 👍

    • @V.D.
      @V.D. Год назад

      Also there is not used many-to-one relationship and because of that there is also vertical replication in a column. This is a bad practice to import data from csv