Answer the question
In order to leave comments, you need to log in
How to get all ForeignKey links?
Good day, stuck on a simple task, there is a user model, he has a field with images:
class User(models.Model):
...
images = models.ForeignKey("Image", on_delete=models.CASCADE, verbose_name="images")
class Image(models.Model):
image = models.ImageField(verbose_name="image")
User.objects.get(login=login).images
Answer the question
In order to leave comments, you need to log in
The task is to determine the number of photos and zero in case of their absence
User.objects.get(login=login).images.count()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question