Adding Extra Fields On Many-To-Many Relationships in Django

Sdílet
Vložit
  • čas přidán 6. 09. 2024

Komentáře • 65

  • @prettyprinted
    @prettyprinted  Před 4 lety +5

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

    • @shahnwazhusain9967
      @shahnwazhusain9967 Před 4 lety

      Sir can you please make a video on deployment of django app on Azure?

    • @pramodmc1921
      @pramodmc1921 Před 2 lety

      Hi Anthony, How can I do this with Flask and Flask-SQLAlchemy

  • @rushas
    @rushas Před 4 lety +8

    Great content! Finally a video with the right pace, relevant information and without tons of pause sounds ("umm...", "so...")
    Good job man. Looking forward for this kinda stuff

  • @serageibraheem2386
    @serageibraheem2386 Před rokem +1

    Dude you solved three problems in a single video. Thanks

  • @armankamal3694
    @armankamal3694 Před 3 lety +2

    Seriously you explained it so well. Thank you

  • @codedjango
    @codedjango Před 4 lety +3

    Wow...I never used a 3rd model till now....definitely going to try this....Thank you

  • @wenbinyang1689
    @wenbinyang1689 Před 2 lety +2

    Excellent. Exactly what I'm looking for. Thanks for the effort.

  • @benonemarcos4720
    @benonemarcos4720 Před 4 lety +2

    Excelent. Thanks for that. I was looking for something like this to solve a problem in my code.

  • @thombou40
    @thombou40 Před 3 lety +5

    When working with a model form, how to handle the additional fields in the table defined by the though argument? I display the many-to-many relationship with checkboxs and for each option I'd like to be able to set the additional fields value (a quantity field)

  • @evouae
    @evouae Před 4 lety +1

    Exactly what i was looking for. Very well explained. Thanks. Do you have a full course ?

  • @ProjectXH
    @ProjectXH Před rokem

    Thank you for this video, you are a gent!

  • @ABMA79
    @ABMA79 Před 3 lety +1

    an amazing explanation.
    thanks a lot.
    but is it possible how to display data on web if you have a many to many relation?
    if you have a course explaining that, it will be great...
    Thanks for the wonderful lesson.

  • @vikashkumarbarnwal4233

    Mind blowing ! It gave me exactly what I need. thank You !

  • @fcomosan
    @fcomosan Před 3 lety +1

    in minute 8, when I run migrate, I got an error:
    ValueError: Cannot alter field erp.Group.teams into erp.Group.teams - they are not compatible types (you cannot alter to or from M2M fields, or add or remove throu
    gh= on M2M fields)
    In my case, I'm working with Team and Group models.
    Thanks

  • @erickvasquezballon6406
    @erickvasquezballon6406 Před 4 lety +2

    Clear and helpfull, for beginers

  • @sinarasoulihaghighi998

    this video helped me a lot

  • @Georgeggg82
    @Georgeggg82 Před 3 lety +1

    Hi Anthony thank you for this, it’s really well explained. One question. How do I query all the students enrolled for a particular course before a specific date?

  • @Dreyard23x
    @Dreyard23x Před 4 lety +1

    excelent video i like how your explain this stuff

  • @thedasilvakid
    @thedasilvakid Před rokem

    Really helpful! Thank you!

  • @rangabharath4253
    @rangabharath4253 Před 4 lety +1

    Awesome as always

  • @ar_sky_blue
    @ar_sky_blue Před 3 lety

    Thank you very much . I finally found a great video 10/10

  • @bobbye.5431
    @bobbye.5431 Před 4 lety

    Nice video ! Thx Anthony
    I think the "create" method does automatically the "save" for you ;)

  • @EricSouzarys
    @EricSouzarys Před 4 lety +1

    Hey Anthony! How would you make the authentication of a project that have both Rest API and Web pages? For example, let's suppose that there is an API for getting data that should be plotted in some graph, but this will be used both in an Android app and in a page rendered by the Flask, but to access the dashboard it's needed to be logged

  • @Ezeiur
    @Ezeiur Před 2 lety

    thanks! this help me a lot

  • @amolgode9843
    @amolgode9843 Před 2 lety

    Hello Sir...!
    I have two models A and B which having many to many relation and form third model E with extra attributes .
    so i want to perform following sql query using django :
    select * from A , B , E where A.id = E.id and B.id = E.id and A.id = '107';
    how i can do..?
    A.objects().filter(e__aid=107)
    geves me only content from A model.
    Plzz Help..!

  • @tochimclaren
    @tochimclaren Před 4 lety +2

    Good tutorial thanks. By the way I have a question I want to ask regarding forms how is the dynamic form on django-quiz achieved. Where questions come after one another with options. For the answer. Thanks.

    • @matiascoco99
      @matiascoco99 Před 3 lety

      I suppose Ajax could make what you ask. Simply POST data from a field, make a function that check that field constantly so you don't have to put a button to POST data. It's better with a GET request rather than POST, but the idea it's the same

  • @be_pie_today
    @be_pie_today Před rokem

    when you already have data you do not want to delete the whole model :) wolud be nice to mention how to migrate from m2m to separate table

  • @IMADETHISACCFORRAY
    @IMADETHISACCFORRAY Před 3 lety +1

    Hey,
    Any clue why we can't display the M2M-field as its normally displayed in the admin area? Gotta use the tabular or stackinline which is kind of annoying.

    • @jpongthep
      @jpongthep Před 2 lety

      I get thia problem too. Can you solve the problem?

  • @rimacrsp9932
    @rimacrsp9932 Před 2 lety

    We can use through to customise many to many relationship in django

  • @monetized1
    @monetized1 Před rokem

    Thank you, this was the best

    • @prettyprinted
      @prettyprinted  Před rokem

      Glad you liked it. Thanks for watching!

    • @user-xu7jz4li7e
      @user-xu7jz4li7e Před 4 měsíci

      @@prettyprinted Can you please do a video on how to create a form using the many-to-many through model? Thank you!

  • @halilibrahimsoyman5797

    I have a complex project and ı dont wan to drop tables. Is there any way for this?

  • @ankitdubey9256
    @ankitdubey9256 Před 3 lety

    hey, is there any way to add more than two columns of same class model to another model having many to many relationship.
    Eg, let say we have a Employee model which contains a recursive relationship with a column say manager, and we want a table named Dispute which is having manyToManyField with these two columns.
    How this can be done?

  • @jinwooje9672
    @jinwooje9672 Před 4 lety +1

    Thank you very much for the great tutorial!
    I have one question. Instead of putting in the 'through=enrollment' argument in courses, is it okay to add it in students?

  • @Kruiger1993
    @Kruiger1993 Před 3 lety

    Great Video!
    just wondering why did you have to comment the two table of Student, Course in order to create Enrollment?

  • @thedupy124
    @thedupy124 Před 2 lety

    Amazing tutorial !

  • @azherali5
    @azherali5 Před 3 lety

    i am not getting table when click on show table, could you please help

  • @muteebakram37
    @muteebakram37 Před 3 lety

    Hi, Good content mate.
    One question: I know django creates a default id as primarykey in manytomany table. I want to have a custom primary key to the manytomany table. How to do it?

  • @tylerwatson3318
    @tylerwatson3318 Před 4 lety +1

    How would I select the variable "final_grade" through the ORM?
    i.e. "anthony.course_set.first().final_grade" --does not work.
    Any suggestions?

    • @RuslanSkiraUkraine
      @RuslanSkiraUkraine Před 3 lety

      anthony.enrollment_set.values('final_grade')
      docs.djangoproject.com/en/3.0/ref/models/querysets/#values

    • @tylerwatson3318
      @tylerwatson3318 Před 3 lety

      @@RuslanSkiraUkraine Thank you. that helped!

  • @lixanderguzman3305
    @lixanderguzman3305 Před 3 lety

    using the through argument, how do I render say student name to templates?

  • @mnogokotin
    @mnogokotin Před 2 lety

    thx for the video )

  • @taihatranduc8613
    @taihatranduc8613 Před 3 lety

    It's very good. Thank you

  • @ruzzan
    @ruzzan Před 4 lety

    Hey man love your vids!!
    Can you make a video on your thoughts on django 3 and asynchronous features?
    Can it be as node async???

  • @khadimhusen
    @khadimhusen Před 3 lety

    I think this is redundant work. As we are already defining three model. Then what is the advantage of manytomany field.

  • @dodokwak
    @dodokwak Před 4 lety

    Thanks.

  • @kaustubhsawant9653
    @kaustubhsawant9653 Před 2 lety

    How to add existing field of a model to a new model

  • @saharamanson1970
    @saharamanson1970 Před 4 lety

    Nice bro

  • @aniketkumbhar9246
    @aniketkumbhar9246 Před 4 lety

    Thabks man!

  • @patrickolsen473
    @patrickolsen473 Před 2 lety

    For anyone playing around with the through-relationship, think long and hard about it. You can't easily change it once you've made the migration. it comes with an error, even if you uncomment all your models, that says "Cannot alter field xxx.xxx.xxx into yyy.yyy.yyy they are not compatible types (you cannot alter to or from M2M fields, or add or remove through= on M2M fields)". I still haven't found a solution although I am not alone on the internet to have experienced this fault

  • @7s9n
    @7s9n Před 3 lety

    💛💛💛💛

  • @omaral-halabiah2851
    @omaral-halabiah2851 Před 2 lety

    print('like '*100)