Using the Inline Form Set Factory in Django (Part 1 of 2)

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ค. 2024
  • In this video I compare using the regular model form set factory with the inline form set factory when it comes to models with relationships.
    Need one-on-one help with your project? I can help through my coaching program. Learn more here: prettyprinted.com/coaching
    Join my free course on working with the database and models in Django: prettyprinted.com/djangodatabase
    Get the code here: prettyprinted.com/l/kGg
    Twitter: / pretty_printed
    Github: github.com/prettyprinted

ความคิดเห็น • 59

  • @prettyprinted
    @prettyprinted  4 ปีที่แล้ว +1

    Join my free course on working with the database and models in Django: prettyprinted.com/djangodatabase

  • @irfanharun
    @irfanharun 2 ปีที่แล้ว

    Thank you so much for making this video. I was stuck for 2 days in a complex form and was able to resolve it after i got my basics clear by watching this video. you are awesome

  • @joseh5085
    @joseh5085 3 ปีที่แล้ว +1

    Nice video man and really helpful!!. I was wasting a lot of time trying to make inline forms

  • @AlejandroPerezCosio
    @AlejandroPerezCosio 3 ปีที่แล้ว

    Exactly what I needed, Thank you!

  • @malikrumi1206
    @malikrumi1206 2 ปีที่แล้ว

    One of your better tutorials, Congrats.

  • @alexissilva6663
    @alexissilva6663 3 ปีที่แล้ว

    thank you, your tutorial is awesome :)

  • @deepdrops
    @deepdrops 3 ปีที่แล้ว

    Awesome! Congrats and Thank you!

  • @Johnnyboycurtis
    @Johnnyboycurtis 4 ปีที่แล้ว

    Awesome tutorial!

  • @chrisogonas
    @chrisogonas ปีที่แล้ว

    Superb!

  • @Websk00l
    @Websk00l 4 ปีที่แล้ว

    This was great! just a quick question, so I am using django all auth for user registeration how can I take the email from that to use as a primary key for my other model ? The other model has the data before the user sign up and verifies.

  • @fadyghalayiny1920
    @fadyghalayiny1920 4 ปีที่แล้ว

    Hi and thanks for your great videos just having one question how can I include current logged in user without showing it in the form
    Thanjs for any help

  • @godspower_eze
    @godspower_eze 3 ปีที่แล้ว +1

    Please could you make a video on how to user modelforms inside of inlineformset factory and how to display errors while using them

  • @vilenczi
    @vilenczi 2 ปีที่แล้ว

    Hi Anthony, thanks for the great video.
    I was wondering, I have a use-case where to the same parent model I'd want to choose from multiple models (and the related forms).
    As an example related to this video would be:
    - you pick the Programmer as a parent the same way as is here (/1, /2...etc)
    - next in a drop-down box you'd choose what form-set to show : Languages AND / OR Hobbies
    - depending on that choice you'd have the appropriate form displayed
    And the rest of the saving logic I guess would be the same.
    Could this be done with model or inline formsets?
    Thanks a lot.

  • @muhammadarsalan3229
    @muhammadarsalan3229 2 ปีที่แล้ว

    Hi Anthony,
    I was going through your video series on formset and it is well explanatory. So thank you for this.
    One thing I was facing a problem with inlineform factory is that
    How to create a parent model entry and multiple child model entries at the same time. I mean keeping instance=None

    • @ytg6663
      @ytg6663 ปีที่แล้ว

      Any solution??

  • @derekkroeker4582
    @derekkroeker4582 2 ปีที่แล้ว +1

    I need 1 ModelForm and 2 inlineformset_factory, how can I do that in one CreateView?

  • @ManishJindalmanisism
    @ManishJindalmanisism 5 ปีที่แล้ว

    hi Anthony. I have a query here. In a project in my organization we are using inlines in admin.py only. I can see two inlines for the main Model Author - books and articles. Both books and articles model have parent child relationship with Author. Now in admin.py we are using formset for books (extending baseinlineformset) and using object of class made by extending BaseInlineFormset in BooksTabularInline. But for Articles we are simply using ArticlesTabularInline. We are not using formset at all. Why this distinction? Can you please clarify where to use formset in admin.py ? What is advantage of using fomset over simple tabularinlines? I will be happy to share admin.py source code if my question is not clear

  • @ericxls93
    @ericxls93 3 ปีที่แล้ว +1

    This is great, can you add a button to add extra fields (rather than refreshing the page)…

  • @khadimhusen
    @khadimhusen 4 ปีที่แล้ว +1

    Very good informative tutorial.
    Can you make tutorial on
    How to create Like django admin
    Tabular inlineform.
    From scratch in our app

  • @rezasadeghi2520
    @rezasadeghi2520 3 ปีที่แล้ว

    how can we Createview preferably CBV a model with its inlines ? Thanks

  • @steve4718
    @steve4718 3 ปีที่แล้ว

    PERFECT example of what I'm doing

  • @sandeshkharat2273
    @sandeshkharat2273 4 ปีที่แล้ว

    hey...How to use Inlineformset factory with Class based view....

  • @addohm
    @addohm 4 ปีที่แล้ว

    Could you make a video on how you set up your windows 10 + ububtu + python venv environment?

    • @prettyprinted
      @prettyprinted  4 ปีที่แล้ว

      I'll consider that. Thanks for the idea.

  • @niteshchaudhary2094
    @niteshchaudhary2094 3 ปีที่แล้ว

    I want to use {% for f in formset %} {{ f.name }} {% endfor %}
    django.core.exceptions.ValidationError: ['ManagementForm data is missing or has been tampered with']
    How to solve this issue???

  • @paulonzervoulakus2685
    @paulonzervoulakus2685 5 ปีที่แล้ว

    Just a simple question. Can you explain the formset using modelformset_factory in template it added a single blank inputfield, but using inlineformset_factory it added 3 blank inputfield. what is the usecase for both as the modelformset_factory is having 1 extra blank inputfield and the other one has 3 extra blank inputfield

    • @prettyprinted
      @prettyprinted  5 ปีที่แล้ว

      Normally you would add one regular model at a time, so that's why you get one field by default. With an inline model, you would expect to be able to add as many as you would like, so they give you three to start with.
      An example of a regular model would be a form that takes in the name of a product. An inline model would be all the colors of that product.

  • @alekszmaalmen7559
    @alekszmaalmen7559 3 ปีที่แล้ว

    Hi=) Your tutorial relies an existing model of Programmer. And if i wanna render a blank inlineformset_factory form, if i'm gonna create a programmer and specify all his languages in a single form as an inlineformset_factory form?

    • @muhammadarsalan3229
      @muhammadarsalan3229 2 ปีที่แล้ว

      you figured out with this problem please tell me the solution

  • @esportsnexus
    @esportsnexus 5 ปีที่แล้ว

    Please make some project series

  • @aksel58
    @aksel58 4 ปีที่แล้ว

    Thanks for this tutorial! Could you please answer how to add parent fields to the resulting form? For example, programmer name?

    • @rodriguitocaicedo
      @rodriguitocaicedo 4 ปีที่แล้ว

      In the fields tuple, add the programmer field. It will show a dropdown with the programmer name, because of the ForeignKey relationship.

  • @themarksmith
    @themarksmith 5 ปีที่แล้ว +2

    Happy new year - just an observation - I like your content but as a Django newbie, some of your videos on Django seem a bit advanced and leave me feeling that they may not be for me at the level I am at - I'm sure others may feel the same so as (hopefully) a helpful suggestion - it might be better if you explain and show an 'idiot proof' practical example of what you are going to be covering at the start of each video as I feel it would help with engagement... as I said I like your content so this is not meant to be a criticism as such... cheers

    • @sinancetinkaya
      @sinancetinkaya 5 ปีที่แล้ว

      Anthony already has "Django Tutorials" playlist and it starts from beginner level to advanced. th-cam.com/play/PLXmMXHVSvS-DQfOsQdXkzEZyD0Vei7PKf.html

    • @themarksmith
      @themarksmith 5 ปีที่แล้ว

      @@sinancetinkaya Thanks for the link - I totally see what your saying but I can't help but feel that doing a recap like I have suggested in my original comment would help with engagement from newbies with his videos - I think 30 seconds or so at the very start just explaining the concept and showing a practical example would really help turn newbies on to his great content... I think the majority of people are not going to watch a long playlist and come back but they might if they can see the practical use of the more advanced concept he is covering in each video...

    • @jonathanwarner2420
      @jonathanwarner2420 5 ปีที่แล้ว

      @@themarksmith "I think the majority of people are not going to watch a long playlist..."
      If you are not ready to learn the basics (e. g. of a long playlist), you should not try to program.

    • @themarksmith
      @themarksmith 5 ปีที่แล้ว

      @@jonathanwarner2420 Thanks for your input - my comment was designed to help Anthony increase his viewership - there are a lot of channels on TH-cam on Django and programming in general and a lot of them either assume that they are the only source of information on the subject and try to spoon feed you their way of doing things or they seem to be simply using their channel to reinforce their own learning...
      Anthony appears to be trying to make a business out of Flask/Django tutorials so my comment was aimed at providing a helpful suggestion to help him with this...
      For example, even though I have found some of these videos on this channel useful I have also found myself feeling that I have wasting my time on a lot of them as the subject was not explained very clearly or was based on a vague premise - this has lead me to move to other YT channels for Django learning and I have identified the reason behind my doing this is that they give better practical examples of the whats and whys of the subjects they are covering...
      These other channels also have more views than a lot of the videos on this channel - which is a shame as this guy deserves more views (and add revenue)for his hard work...

    • @jonathanwarner2420
      @jonathanwarner2420 5 ปีที่แล้ว

      @@themarksmith May be he should make a note in his Tutorial-Title, e. g. Beginner, Intermediate/Advanced or sth. else.
      This tut for example was an inquiry of his subscribers in the comments of another form-tutorial. May be an advanced tag would have helped.
      "... which is a shame as this guy deserves more views"
      I totally agree!

  • @addohm
    @addohm 4 ปีที่แล้ว

    This video is specific to editing an objects children. What if I want to create an parent and modify it's children all in one go?

    • @tommyranger9228
      @tommyranger9228 4 ปีที่แล้ว

      Yeah... I think this tutorial is impractical and stupid.

    • @muhammadarsalan3229
      @muhammadarsalan3229 2 ปีที่แล้ว

      Hey did you figured out the solution if yes please tell me the solution

  • @hebertvillafuerte7223
    @hebertvillafuerte7223 4 ปีที่แล้ว

    please.. tutorial code?

    • @prettyprinted
      @prettyprinted  4 ปีที่แล้ว +1

      Here you go: prettyprinted.com/l/kGg

  • @richardlong2412
    @richardlong2412 5 ปีที่แล้ว

    do you have a udemy course?

    • @prettyprinted
      @prettyprinted  5 ปีที่แล้ว

      Yes, you can go here to see what's available: www.udemy.com/user/anthony-herbert-2/

    • @richardlong2412
      @richardlong2412 4 ปีที่แล้ว

      Any chance you have Django course? I only see flask? You give great examples and easy to follow videos.

    • @prettyprinted
      @prettyprinted  4 ปีที่แล้ว

      @@richardlong2412 For now, I only have a Django course on my website: prettyprinted.com

  • @mayanktripathi4u
    @mayanktripathi4u 5 ปีที่แล้ว

    Hi, could you please explain us the management_form in Django with an example.

    • @prettyprinted
      @prettyprinted  5 ปีที่แล้ว +1

      OK, I'll consider making a video about it.

  • @thatsenam9183
    @thatsenam9183 4 ปีที่แล้ว

    Its complicated

  • @tommyranger9228
    @tommyranger9228 4 ปีที่แล้ว +1

    This is stupid! Why do you have to save the programmer first before you can save any language/s? Why not create a new programmer along with new languages in the same form?

    • @onlysolo
      @onlysolo 3 ปีที่แล้ว +1

      yes this is much more interesting and useful and what i was searchign for , but still the tutorial is ok as an inctroduction

    • @muhammadarsalan3229
      @muhammadarsalan3229 2 ปีที่แล้ว

      If you figured out the solution please let me know please

    • @tommyranger9228
      @tommyranger9228 2 ปีที่แล้ว +1

      @@muhammadarsalan3229 I already did but I already moved on from using Django. I'm more focused right now on Rust development. I'm not sure if I still have my codes.

    • @muhammadarsalan3229
      @muhammadarsalan3229 2 ปีที่แล้ว

      @@tommyranger9228 ok thanks

    • @tommyranger9228
      @tommyranger9228 2 ปีที่แล้ว

      @@muhammadarsalan3229 Give me your email address so I can send the codes if I find them.