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
Join my Django Database Essentials course here: prettyprinted.com/djangodatabase
This helped solve the problem I was struggling with for like two hours, thank you!!
Pretty simple and straightforward explanation. Thank you for sharing it with us :)
this is what i've been looking for. Thank you :)
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
You're welcome! I'm glad you like the videos.
Thank you my dude. This really helped me.
great... explained so neatly... thank you.
God bless you man... You save an hour of mine. 👍👍
Thanks Anthony !! Really helpful 👍
Thanks ! very clear explanation
Excellent video, thanks!
Thanks for so helpfull video!!!
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
Thanks for this video
Thanks for explain is pretty simple.
If I have two foreignkey from two different classes . Can they get the same related_name?
bless your heart!
So the related_name need only for the ORM ? what the analogy in SQL?
you are a life saver
Awesome...as always :)
Thanks for watching!
Thanks a lot
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.
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 !!!
Thank you.
thx Anthony
hi bro can u suggest me what i have to do after Django web-development.I m confused what to start next
learn some frontend, and start making web apps
thanks for the help man, But is null=True same as blank=True?
no
null means that attribute could be equal to zero
e.g. item_quantity could be zero, but it can`t be empty
good
Is it just curiousity or math majors just happen to know a lot more than just math
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?
math.major.all() ==> why can't I do this?