How to Use the Related Name Attribute in Django

Поділитися
Вставка
  • Опубліковано 21 лип 2024
  • In this video I will talk about how to use the related name attribute in Django. This attribute is important for models that have multiple foreign keys to the same model.
    Need one-on-one help with your project? I can help through my coaching program. Learn more here: prettyprinted.com/coaching
    Join my Django Database Essentials course here: prettyprinted.com/djangodatabase
    Get the code from this video here: prettyprinted.com/l/Ch1
    Twitter: / pretty_printed
    Github: github.com/prettyprinted

КОМЕНТАРІ • 36

  • @prettyprinted
    @prettyprinted  4 роки тому +3

    Join my Django Database Essentials course here: prettyprinted.com/djangodatabase

  • @dianalovette2078
    @dianalovette2078 3 роки тому +1

    This helped solve the problem I was struggling with for like two hours, thank you!!

  • @cassiosalvador7961
    @cassiosalvador7961 4 роки тому +2

    Pretty simple and straightforward explanation. Thank you for sharing it with us :)

  • @atilaguler376
    @atilaguler376 5 місяців тому

    this is what i've been looking for. Thank you :)

  • @madukomablessed4712
    @madukomablessed4712 4 роки тому +1

    Great content Anthony, A huge fan from Nigeria. I am about to begin your Django tutorial series. I just finished Flask Series and I'm pretty good with Flask. :) Continue to make good contents for us. Thanks a lot

    • @prettyprinted
      @prettyprinted  4 роки тому

      You're welcome! I'm glad you like the videos.

  • @chasefite9241
    @chasefite9241 3 роки тому +1

    Thank you my dude. This really helped me.

  • @aditya.pradhan
    @aditya.pradhan 4 роки тому

    great... explained so neatly... thank you.

  • @RajanKumar-ol2qf
    @RajanKumar-ol2qf 3 роки тому

    God bless you man... You save an hour of mine. 👍👍

  • @prateeksarangi9187
    @prateeksarangi9187 2 роки тому

    Thanks Anthony !! Really helpful 👍

  • @yorker3148
    @yorker3148 2 роки тому

    Thanks ! very clear explanation

  • @MagnusAnand
    @MagnusAnand 3 роки тому

    Excellent video, thanks!

  • @dinmukhammedtleuzhanuly1225
    @dinmukhammedtleuzhanuly1225 3 роки тому

    Thanks for so helpfull video!!!

  • @pranayreddy7303
    @pranayreddy7303 4 роки тому

    what if we have another class object attribute in subject model and how can we relate it to the student model class object attribute minor using the foreignkey

  • @imanhpr
    @imanhpr 3 роки тому

    Thanks for this video

  • @mahmoodali2085
    @mahmoodali2085 2 роки тому

    Thanks for explain is pretty simple.
    If I have two foreignkey from two different classes . Can they get the same related_name?

  • @lastmaj
    @lastmaj 3 роки тому +1

    bless your heart!

  • @RuslanSkiraUkraine
    @RuslanSkiraUkraine 3 роки тому

    So the related_name need only for the ORM ? what the analogy in SQL?

  • @jasondhakhwa1179
    @jasondhakhwa1179 3 роки тому

    you are a life saver

  • @codedjango
    @codedjango 4 роки тому +1

    Awesome...as always :)

  • @amirehsani1044
    @amirehsani1044 Рік тому

    Thanks a lot

  • @shansabitjourney127
    @shansabitjourney127 3 роки тому

    Hi brother, would you please help me, I am new in Django I have two models by name of Buildings(Name, Status, Descriptions) and Floors (Building as foreign key , Name, Status, Descriptions) now in the Floors form I want to display only the building which their status is true.

  • @Youssouf_Maroci
    @Youssouf_Maroci 3 роки тому

    HELLo... i want to do a oniline courses website ... and each course should have lectures but when i call it in the template i get the course name repeated with only one lecture .. help plz !!!

  • @antoniocalheirosneves
    @antoniocalheirosneves 4 місяці тому

    Thank you.

  • @medoabdin480
    @medoabdin480 2 роки тому

    thx Anthony

  • @shubhamsharma9756
    @shubhamsharma9756 4 роки тому

    hi bro can u suggest me what i have to do after Django web-development.I m confused what to start next

    • @creepermanpro
      @creepermanpro 3 роки тому

      learn some frontend, and start making web apps

  • @ramyaksharma7261
    @ramyaksharma7261 3 роки тому

    thanks for the help man, But is null=True same as blank=True?

    • @nbzp28
      @nbzp28 2 роки тому

      no
      null means that attribute could be equal to zero
      e.g. item_quantity could be zero, but it can`t be empty

  • @user-bf7bz2fs1t
    @user-bf7bz2fs1t 2 роки тому

    good

  • @akifazwad1489
    @akifazwad1489 2 роки тому

    Is it just curiousity or math majors just happen to know a lot more than just math

  • @ches_ter6842
    @ches_ter6842 2 роки тому

    class Client(models.Model):
    name = models.CharField('Name', max_length=250)
    surname = models.CharField('Surname', max_length=250)
    phone = models.CharField('Phone', max_length=10)
    ...
    def __str__(self):
    return str(self.surname ) + ' | ' + str(self.name)
    class Checklist(models.Model):
    client_name = models.ForeignKey(Client, on_delete=models.CASCADE)
    point1 = models.BooleanField('point1', default=False)
    point2 = models.BooleanField('point2', default=False)
    point3 = models.BooleanField('point3', default=False)
    ...
    def __str__(self):
    return self.client_name
    How can i provide or add all Client properties to Checklist instance? (note: I create Checklist object via forms.py) And when it's done how to get an access to Client properties using Checklist object?

  • @bakalimao9335
    @bakalimao9335 Рік тому

    math.major.all() ==> why can't I do this?