Django & HTMX - importing CSV files with django-import-export

Поділитися
Вставка
  • Опубліковано 17 вер 2024

КОМЕНТАРІ • 17

  • @seydinaoumarsamabaly1806
    @seydinaoumarsamabaly1806 8 днів тому +2

    The simplest way to use this package explained in the simplest way by the Master ! Thank you for all !

  • @repotranstech9614
    @repotranstech9614 8 днів тому +2

    The best Django htmx channel

  • @ericmuijs1938
    @ericmuijs1938 8 днів тому +1

    Great tutorial, what is maybe nice to add is the example view, which shows the examples that will be imported.
    For the end users this helps to confirm that the data is interpreted correctly. Especially with csv important. Just like in the admin.

    • @bugbytes3923
      @bugbytes3923  7 днів тому

      Thanks! Great suggestion - that would be a cool extension to this for validation of the data.

  • @mpicuser
    @mpicuser 8 днів тому +1

    Thank you again for this great video!

    • @bugbytes3923
      @bugbytes3923  7 днів тому

      Thanks for watching and commenting!

  • @kariminic
    @kariminic 8 днів тому +1

    I was damned to implement my backend in go and bootstrap for styling. I’m pretty comfortable with python/django and since I’m transitioning to go I thought this was the perfect project to toy along with. Got stuck along the way and gave up😂. I’ll first complete it in your stack and then convert it to golang. I should be able to code it to tutorial no 12 in a day or two by just looking at intro demo expectations on each video. Thanks for introducing plotly btw, I’m still exploring the trade off with chart js in terms of speed and efficiency given how we retrieve data for visualization.

    • @bugbytes3923
      @bugbytes3923  7 днів тому

      Thanks and good luck with the Go implementation! I have a big goal to do more Go content, but the priority has mostly been Python/Django for a while.

  • @wolpumba4099
    @wolpumba4099 3 дні тому

    *Importing CSV Data with Django, HTMX, and django-import-export*
    * *0:00** Introduction:* The video demonstrates importing CSV data into a Django application using the `django-import-export` package and HTMX for enhanced user experience. This feature allows users to bulk load predefined data, saving time compared to manual entry.
    * *0:56** UI Enhancement:* A new upload icon is added to the user interface using Heroicons, providing a visual cue for the import functionality.
    * *3:19** HTMX Integration for File Uploads:* The upload icon triggers an HTMX `GET` request to an "import" URL, dynamically loading a file upload form within the existing page. The form utilizes `HX-Encoding="multipart/form-data"` and `HX-Post` for handling file submissions.
    * *6:19** HTMX File Upload Considerations:* The video highlights the importance of specifying `multipart/form-data` encoding for HTMX file uploads and using an `` element within the form.
    * *7:43** File Input Styling:* DaisyUI component classes are used to style the file input element, ensuring consistency with the overall application design. The `accept=".csv"` attribute is added to restrict file types.
    * *11:50** Handling CSV Import with django-import-export:* The `django-import-export` package is employed to process the uploaded CSV file. A `TransactionResource` class, defined in a previous video, is used to map the CSV data to the Django model.
    * *12:13** Import ID Fields:* The `import_id_fields` attribute in the `TransactionResource` class is configured to prevent duplicate entries during import, similar to a unique constraint.
    * *13:54** Data Loading with `tablib`:* The `tablib` library's `DataSet` object is used to load data from the uploaded file. The `load` method reads the file content and parses it as CSV.
    * *14:51** Import Process with Dry Run:* The `import_data` method of the `TransactionResource` is called with `dry_run=True` to simulate the import without affecting the database. This allows for error checking before committing changes.
    * *17:21** Attaching User to Imported Transactions:* To associate the logged-in user with the imported transactions, the `after_import_instance` method of the `TransactionResource` is overridden. This method sets the `user` field of each imported transaction instance to the current user.
    * *22:55** Summary and Benefits:* The video summarizes the entire import process and emphasizes the benefits of using `django-import-export` and HTMX for streamlined data management. The combination of these tools allows for efficient bulk data loading and user-friendly file upload experiences within Django applications. [From seydinaoumarsamabaly1806's comment] Viewers have praised the video for its clarity and simplicity in explaining the process.
    * *25:53** Conclusion and Call to Action:* The video concludes by encouraging viewers to support the channel, subscribe, and leave comments or suggestions for future content.
    I used gemini-1.5-pro-exp-0801 on rocketrecap dot com to summarize the transcript.
    Cost (if I didn't use the free tier): $0.10
    Input tokens: 25161
    Output tokens: 673

  • @MagnusAnand
    @MagnusAnand 8 днів тому +1

    great video!

  • @alexdubkov6998
    @alexdubkov6998 8 днів тому

    Super! As always

  • @frameff9073
    @frameff9073 8 днів тому +1

    good thank you god