Inline Formsets | Django (3.0) Crash Course Tutorials (pt 11)

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ต.ค. 2024

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

  • @DennisIvy
    @DennisIvy  3 หลายเดือนก่อน

    Don't forget to check out my Complete Django course! dub.sh/NvGboTI

  • @caiopjv
    @caiopjv 7 หลายเดือนก่อน +1

    Thank you so much! 3 years later, this video helped me so much! I spent days on chatgpt and couldn't learn what I've learned here. I hope you don't stop posting

  • @umar-toirov
    @umar-toirov 3 หลายเดือนก่อน +1

    This course the best I have even even seen though after 4 years

  • @rishupal7952
    @rishupal7952 4 ปีที่แล้ว +10

    And in chandler's voice...COULD IT BE ANYMORE PERFECT!

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

      @Azizbek Xushnazarov man you have to watch friends she cant explain the joke

  • @maciejcelinski4496
    @maciejcelinski4496 4 ปีที่แล้ว +7

    If You like me forget to update 'updateOrder' view. You can do this in "order_form.html' .. in input place this code:
    {% csrf_token %}
    {% if form %}
    {{form}}
    {% endif %}
    {% if formset %}
    {{ formset.management_form }}
    {% for form in formset %}
    {{ form }}
    {% endfor %}
    {% endif%}

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

      It works for me. Thank you so much.

    • @nhfx2261
      @nhfx2261 9 หลายเดือนก่อน

      thanks learned new things

  • @wassimharakeh8699
    @wassimharakeh8699 4 ปีที่แล้ว +5

    I was trying to message you but i had no idea where to reach you from, so i will just type my message right here, in this legendary django series i was following recently. I followed you step by step and currently i'm in part 11..it's the coolest tutorial i have ever watched, CAN'T DESCRIBE HOW HAPPY I AM while learning from your super skills!!
    It's literally the first time where i feel comfortable building a project while understanding every single step😍😍
    It's been like 2 months since i subscribed to your channel, and i thank god i did.
    I just have one question to ask..
    In almost every django tutorial, in the first steps of the project where we work with cmd and creating our directory, the instructor creates a virtual environment before django-admin startproject ....
    While in this series, we are building our project without any virtualenv created
    Why? 🤔🤔
    I'm literally enjoying every minute building this CRM website and only have this question
    and again, THANK YOU. 🙏🙏🙏

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

      About the virtualenv, it is for isolate the running system django is using. If you dont have the need of isolating it, then venv has no use.

  • @abenitesema1516
    @abenitesema1516 4 ปีที่แล้ว +3

    i'm a high school student and this is the coolest tutorial
    if this fits to me this means any one can learn a lot from this tutorial , thank you dennis !!!!

  • @johnnyli2732
    @johnnyli2732 4 ปีที่แล้ว +14

    Hi Dennis, Great Tutorials! Having one question on this inline formsets. How can I have an 'add' button to control the amount of forms I want dynamically? Tried with jquery, but the data was submitted to database instead of creating an extra form on the page..

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

      use button tag with type="button" for add button

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

      You can follow this article to add “Add More” button.
      www.letscodemore.com/blog/django-inline-formset-factory-with-examples/

  • @adamhughes5527
    @adamhughes5527 4 ปีที่แล้ว +3

    These are really great and covered a bunch of things my knowledge was a bit vague on! :D

  • @anindyasikdar3221
    @anindyasikdar3221 4 ปีที่แล้ว +12

    I'm confused with when to use instance and when to use initial. Are they interchangeable?
    Any help will be appreciated.
    Thanks!

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

      instance refers to one of the objects in a model. Initial pre-fills form's fields. Using the Instance argument does pre-fill the form, but it's an "extra feature", not the main functionality.

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

      "No, there's quite a difference. "Initial" is used to set the initial
      values and is quite appropriate when a *new* model instance is going to
      be created. The "instance" is used when you want the ModelForm to be
      used to update an existing instance of a model. Since Django does not
      currently incorporate mind-reading technology, if the two parameters
      were merged into one, the framework wouldn't know whether it's meant to
      be updating an existing instance or creating a new one."
      from: groups.google.com/g/django-users/c/wi6yOo3N0FU

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

    Thanks! A good improvement would be trying to create one order with multiple items, since with this model, you have to generate multiple order if you have more than one item.

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว +6

      Good idea :)

    • @euriperez9586
      @euriperez9586 4 ปีที่แล้ว +2

      @@DennisIvy Agreed with this guy, could be awesome to create one order with multiple items, thank you so much for this series.

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

      @@DennisIvy it s just reminder if possible and thanks a lot for your effort ! it s really a golden tuto

  • @JKahlonMusic
    @JKahlonMusic 4 ปีที่แล้ว +12

    Absolutely amazing content man. keep it up.

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

      Thank you thank you thank you!! I appreciate the support so much!

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

    Hey Dennis!
    Thanks for this amazing content.
    If possible, could you please make a video on how to create a popup for deleting or updating anything in Django?

    • @chennai-media7920
      @chennai-media7920 3 ปีที่แล้ว +1

      Do u got any tutorial for that so far, if yes ,share it with me please.

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

    Never Learned Django better than this !!!

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

    Please make a more advance course. We will ready to pay you. Amazing tutorial. This is a real tutorial with point to point understanding.

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

    Next traversy media? Road to 1 million subscriber bro. Thank you so much for the tutorial. Really really appreciate it

  • @kimhongsieng6457
    @kimhongsieng6457 4 ปีที่แล้ว +2

    It is nice for you inline formset video. if we have new customer and we want to make an order during add new customer, what should we do?

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

    Nice tutorials, wonderful content. i have been watching the playlist since morning this is pretty neat. i was able to understand each and everything

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

    1. Why is there a "delete box" in the Order Form ??????? Do we need it ? Do we get rid of it ? 2. It would have been nice to see the other method, that does not use the loop. 3. I wonder if you could use the inline form feature to create a kit or package of individual parts that someone could buy, enter the package SKU and the form expands the package into individual orders. ie BBQ package .... includes BBQ grill, propane tank, and cooking utensils. Love to see it.

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

    I am not able to get multiple formset after changing the code what might be the reason.
    Didn't get a delete checkbox also as shown in the video 6:48. Not able to loop also

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

    Hey Dennis..
    When i try to pass urlspatterens =[ path('create_order/'/, views.createOrder, name= ' create_order')] dynamically, it throws an error [reverse match not found and stuff like that]. Everthing is good i checked every url even templates but nothing helps. But without the dynamic url and customer initials, it works fine. Plz help

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

    Any tutoria for django on dropdown box with typing options. Because when there are more than 100 items in dropdown it is difficult to find and select.

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

    you a real G for this one Dennis

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

    Quick question. I have several forms in one view function, it all works fine and flawlessly, but i cant seem to add the inline formsets to work correctly with the rest. i have tried everything i know so far and also read documentations online, have you implemented such a logic? if yes, how did you do it correctly?

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

    This had really helped soo much!!! We all are thankful to u..
    much love from india

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

    Hey regarding the inline form sets ... is there a way to implement features such as adding fields and deleting fields individually, I searched the whole django world for this and literally your the closest one I can get

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

      Search dynamic django forms. There are some articles online now.

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

    I've been looking for this!! Really appreciate this tutorial!! :)

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

    Give us more django tutorials Dennis!!

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

    Hi Dennis, thanks for this selfless effort. It really help. I got to a stage where I got stuck with one page handling multiple forms. One to update exiting instance, one to add new entry data. Could you make a video address how these can be done?

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

    Hi can you show us an example if I want to include current logged in user without showing it in the form

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

    Adding formsets breaks updating orders (/update_order//)

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

    Hi Dennis. Using the URL "path ('create_order / /', views.createOrder, name =" create_order "),", I can no longer display the dashboard. What could I miss?
    Here is the message that appears : django.urls.exceptions.NoReverseMatch: Reverse for 'customers' not found. 'customers' is not a valid view function or pattern name.
    Thank you in advance for this series of tutorials.

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว +2

      Can you please send a screenshot or you views.py file to dennisivy11@gmail.com? I’ll take a look when I have a second

    • @Chinmay_395
      @Chinmay_395 4 ปีที่แล้ว +2

      @@DennisIvy Even I am having this issue, will you please share the solution.

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

      I am also having the same problem, if you have got the solution would you care to share it please.

    • @julianbazanaguirre8439
      @julianbazanaguirre8439 4 ปีที่แล้ว +2

      I have been repetedly having the same issue, there is this user Искандар Ходжаев
      below that proposes to eliminate completely the previous reference to the create order customer in Dashboard, in my case I had also commented out that line and it was not working, I wrote it again right now and it is working fine. I also tried a second time, to leave the button (instead of deleting it) and faced the same issue. So I guess it was true that the interpreter was not acknowledging the symbols. Any idea of that?

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

      Yes i am having the same exact issue :S

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

    You are great Sir Thank you creating Django series and it's really Helpful for me.
    Really Thank you

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

      My pleasure :) Thank you for leaving feedback. This helps me alot.

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

    best, the way you teach ,everything awesome

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

    getting error 9.01
    NoReverseMatch at /
    Reverse for 'create_order' with no arguments not found. 1 pattern(s) tried: ['create_order/(?P[^/]+)/$']

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

    what if I want to do both? have a button to create a new order from scratch but also have a button in the customer page where the customer information will be automatically pulled

  • @IiVaNaAa13
    @IiVaNaAa13 4 ปีที่แล้ว +3

    Hi, you are great, I really enjoy this course, but I have question. After adding formset, update button is not working, how to fix that?

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว +5

      Yes, sorry about that. I updated this in the source code but I'll make a video fixing this bug soon. The problem is that in "order_form.html" we reference the "formset" but in the "updateOrder" we pass in "form". The fix for now is to change the context dictionary in the "createOrder" view to pass in the formset as form: context = {'form':formset}.
      Then change the name in order_form.html for "form" instead of formset & loop the the form by field:
      {% csrf_token %}
      {{ form.management_form }}
      {% for field in form %}
      {{field}}
      {% endfor %}

      Hope this makes sense for now. I'll make a video soon on this.

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

      @@DennisIvy Thank you, I saw changes for order_form in source code, but havent for context in createOrder. . It works now, thanks for explanation, you are really great!

    • @DennisIvy
      @DennisIvy  4 ปีที่แล้ว +2

      @@IiVaNaAa13 Awesome! Sorry about the error, Keep at it my friend :)

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

      @@DennisIvy ok, I see what u mean, and thanks for posting the solution here. Could you please explain why is this happening? Because when I click submit after completing more field, it doesnt call the updateOrder view, or does it? I am bit confused here. I placed the fix u mentioned and it is working now.

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

    Denis I wish I can steal your brain. You are an amazing instructor. Thank you alot for this wonderful tutorial.

  • @Ambition-Tomoh
    @Ambition-Tomoh 3 ปีที่แล้ว

    please how to add select2 in product to choice easy if large amount of choices please I try to add and do java to html not work

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

    Perfect video!!!!, what if I want to add ynamically a form to a formset ???

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

    Thanks for your passionate work , great tutorial indeed !!

  • @DHANANJAYBHADAURIA
    @DHANANJAYBHADAURIA 4 ปีที่แล้ว +2

    this is exactly what I was searching. thank a lot

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

    my update method not working is this because of deprecation or else, delete create are working but after formset update is not working

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

    Bon tuto, puis-je avoir un exemple détaillé de django formtools combiné à un formset. J'ai déjà regardé la documentation. Merci

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

    Hi Dennis, awesome tutorial keep it up man! I have a small issue with initializing the order form with the current instance of the customer. I have followed your code but mine does not populate the customer field . Any suggestion ? Thank you.

  • @3DGFan9000
    @3DGFan9000 2 ปีที่แล้ว

    How would we make the number of items dynamic rather then setting for example 10 like you did? How would i add a button to add another row?

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

    We can you only place one item per order, should this be changed to allow for multiple line items ? What about ordering packages ie some computer component companies generate build lists for computer builds of various attributes and prices. How cool would it be to create a 'package list' as a item, order that item and it automatically generates a multiple line order of the individual components. Just a thought. Also looks like the timestamp in settings.py has not been set for the proper timezone. Either that or format the Date Order to drop the time.

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

    Welcome to TH-cam 😊

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

      Thank you :)

  • @KamranMmmdv
    @KamranMmmdv 4 ปีที่แล้ว +55

    Create a Udemy course, man, let us pay for these perfect tutorials.

    • @julianbazanaguirre8439
      @julianbazanaguirre8439 4 ปีที่แล้ว +13

      you can go to the link where the source code is, and donate money for this. I think it truly deserves to get some good feedback monetary speaking because the content is absolutely gold!

    • @EOO-Stand
      @EOO-Stand 4 ปีที่แล้ว +1

      @@julianbazanaguirre8439 in total agreement

    • @pameng5235
      @pameng5235 4 ปีที่แล้ว +3

      Salam.pulu olmayan neynesin

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

    Very nice video thank you so much! I love your tutorial. Sir one thing just I have to ask. Order form after submitting the form and redirecting to the dashboard reverse error is showing. How can I fix that one?
    Please tell me. Thanks in advance.

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

    How could I create an Costumer and add their Order in the same form? as in the Django Admin.

  • @Mizuh4
    @Mizuh4 3 หลายเดือนก่อน

    Can someone help me arrange the fields inline? My formset automatically creates forms with DIVs in a block format. Thank you!

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

    Followed everything still the form not saving, :( I do not know anymore what I am missing..any help?

  • @Alliswelltoday
    @Alliswelltoday 4 ปีที่แล้ว +2

    Dennies please make vedios on DJANGO REST APIS

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

    Great tutorial!!! Btw... Is there a way to pass two instances?? For example one will be a Profile model (just like this tutorial) AND the other model is "Proyect", which should have just the proyects of the user logged

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

    Finally i found you :v ... Thanks for your content :)

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

    sir plz tell me that how can i customize formset in this (add css in button in formset plz answere)

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

    You are a life savor man!!!

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

    Thank you Dennis!

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

    Hi!
    I am using modelformset_factory and trying to save data on different data base like
    form.save(using=“abc”)
    This work fine with form but when using with modelformset shows an error that un aspected argument “using”
    How to solve please

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

    also... would it be possible to have a formset where one of the initial values is either a formset or inline formset? :o

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

    what is difference between "initial" used here to pre-fill the form field and "instance" used in updateOrder form

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

    Where do you get names or labels of the fields in your form?
    PS: great tutorial

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

    Hi Dennis, first thanks for great and also clear series.
    I bump into one question which is "inlineformetset" would automatically hide the foreign key from the form, however it's not what I looking for. Wondering is that possible to show FK? thanks

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

    Nice Tutorials series, i know this question is not great, but how to get ride of the "-----------" in choices fields, i tried to add a blank tuple in the choices field but still the same

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

    What about saving (Inline) Formsets that have a Unique Constraint? When getting already existing values from the database with the intent to update them, it tries to insert them instead, resulting in an error. How do you handle that?

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

    How should i add more field to child model. As its now 5 or 7! If i get more child field then what should I do.

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

    How can inline form update and add more button.. Only django

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

    any knowlede about rendering validation errors on dynamic added fields? :x

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

    Wow great. Exactly what i m searching. Thank you. It'll help me a lot.

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

      Happy to hear that!

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

    if someone has the error: " 'set' object has no attribute 'append' "
    then you should change the 'fields' data type set to tuple.
    I mean you should use normal brackets not curly braces.
    OrderFormSet = inlineformset_factory(Customer,Order,fields={'product','status'})
    New: OrderFormSet = inlineformset_factory(Customer,Order,fields=('product','status'))

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

    How can implement multiple models in one view with one to one relationship and shared model
    Example:
    I wants to make reports (daily, weekly and monthly)
    All reports must have a project to report about, and must have two extra models (staff workers and.....) and (machines cars and ......)
    So I can’t figure the relationship
    Please help.

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

    Thanks so much Sir...So helpful. Please need part 13..please...of crm

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

    this tutorial is super i have ever seen

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

    Is it possible to do a dependent drop down list with an inline formset?

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

    You are doing a great job... But you have to work on your camera, from the eleventh video, it became blur

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

    Your tutorial is awsome...big thank you

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

    Thanks for sharing such a good tutorial.
    In the inline formset, could you please put some light on how we can do dynamic add new row for Order... instead of relying on extra parameter in inlineformset_factory.
    I mean customer can keep adding new order if he wish else default display 1 or 2.

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

      I am searching the whole internet to do that but I still couldn’t get it , it would be a life saver if he shows how to do that !

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

      @@prajithkrish5230 there are many videos made with javascript

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

      You can follow this tutorial:
      www.letscodemore.com/blog/django-inline-formset-factory-with-examples/

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

    kindly make tutorial on dependent/chained select options. Like Car Make, Model and trim. if user selects a Car make then next select box should show models of only the selected car make, and then trim select option should be according to the selected model.

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

    8:20 "i just want you to be funnier with this" lol

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

      i can't save data what can i do ?

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

      @@ssd7199 whats your error?

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

      @@shawnbeans7389 i don't have any error but data can't save and redirect to dashboard page any idea to slove this problm

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

      @@ssd7199 make sure you do action="post" in your html when posting data

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

      @@shawnbeans7389 yes i make it but no save action

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

    How to save this 5 products and status in one bill
    Example:
    1.productname status
    1.productname status
    2.productname status
    3.productname status
    4.productname status
    5.productname status

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

    Thanks for the great series . at 9:54 can't we just take out the instance argument from the OrderSetForm() rather than passing querset none. It worked fine for me taking the instance out of there let me know if it can cause problem.

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

      We have to specify the parent model for the orders.
      Otherwise how would you link the submitted orders to a particular customer?

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

    What about forms.py file than i guess we should remove that because now we are using inlineformset?

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

    How can i filter foregn key in formset based on login user?

  • @banaras.wala.foreignaala
    @banaras.wala.foreignaala 4 ปีที่แล้ว

    So far so good

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

    How can we store multiple form in database??

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

    Yes ok but how to make it dynamic so with an add button below. Because this would give the right UX

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

    It's cool. But i have a question Boss. When you added order from customer panel it counted 3 orders for 3 individual products. If i want, there is a "Invoice no." field for each order which i input during order creation. When i create order with this "Invoice no." it will count 1 order. How can i do this?

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

      Just replied to your email. Thank you for attaching your code and being so descriptive :)

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

      I showed you an easy way but the best method is probably to use signals (I'll do a tutorial on this). Also the way I check for duplicates can be improved. I just used the first thing that came to mind.

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

      @@DennisIvy I am really happy to code with you Boss. You are so caring with your students.

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

      Walid Newaz it’s my pleasure to help :)

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

    when I create order and submit it ives error with pk=id, I just fix it like this
    def createOrder(request,pk):
    if request.method=='POST':
    form=OrderForm(request.POST)
    if form.is_valid():
    form.save()
    return redirect('/')
    customer=Customer.objects.get(id=pk)
    form=OrderForm(initial={'customer':customer})
    context={'form':form}
    return render(request,'accounts/order_form.html',context)

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

    Is there a way to do the same with createview??

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

    Hi Dennis, sorry to ask this, what is instance?

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

    At 9:56 can't we just do formset = OrderFormSet() so as avoid polpulating the formset?

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

    i dont have that view button not included on your tut why?

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

    how can we add forms dynamically in formset?

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

    Hi Dennis
    First and foremost thank you so much for your amazing content. Would it be possible to do a video about chained input fields using model forms?
    Best regards from Denmark

  • @grzegorz-gregmika8339
    @grzegorz-gregmika8339 4 ปีที่แล้ว

    Again great job! I like your pace and how you explain things. Please keep on. I have a question, how to handle this Delete section. I removed it in js but I don't like it:
    document.querySelectorAll("[id$='-DELETE']").forEach(e=>{
    e.remove();
    });
    document.querySelectorAll("[for$='-DELETE']").forEach(e=>{
    e.remove();
    });

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

      Can you send me your source code? I think i see what you are trying to do but I don't know enough to give you the best answer. (send to dennisivy11@gmail.com)
      Are you trying to select multiple orders in a checkbox's and delete in one submission?

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

    I still have the problem with ['ManagementForm data is missing or has been tampered with']. Can you tell me why? Here are my codes:
    *******
    def createOrder(request,pk):
    OrderFormset = inlineformset_factory(Customer,Order,fields=("product",'status'))
    customer=Customer.objects.get(id=pk)
    formset = OrderFormset(instance=customer)
    #form = OrderForm(initial={'customer':customer})
    if request.method == 'POST':
    #form = OrderForm(request.POST)
    formset = OrderFormset(request.POST, instance = customer)
    if formset.is_valid():
    formset.save()
    return redirect('/')
    context = {'formset':formset}
    return render(request,'accounts/order_form.html',context)
    *******
    {% extends 'accounts/main.html' %}
    {% load static %}
    {% block content %}


    {% csrf_token %}
    {{ formset.management_form }}
    {% for form in formset %}
    {{ form }}
    {% endfor %}


    {% endblock %}

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

      Check the source code then you can solve it, because it is different from video code !

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

      fields=('product','status')

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

    Hey, please make a video on importing data through views with django-import-export

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

    form = OrderForm(initial ={'customer': customer}) is not auto filling the customer's name in the forms

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

      I'm aware this is coming after 4months, but for anyone who is confused:
      remove the "else" code bit.
      else:
      form = OrderForm()
      with: " form = OrderForm(initial ={'customer': customer}) " towards the top of the createOrder function, you are creating an OrderForm instance (" form ") which is temporairly loaded (at runtime) with the values in the " initial " dictionary.
      If you continue to have that bit of code along with the "else" code (towards the bottom of the function), the "else" code bit takes precedents (because the code is read from top to bottom) and ignores populating the form with what's in the initial dictionary. The "else" code creates an unbounded form instance.
      Hope it makes sense.

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

    hii what is the syntax theme that u are using

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

      I just added bootstrap for styling.