B
B
bituke2021-10-03 11:18:53
Django
bituke, 2021-10-03 11:18:53

How to link objects to the same object via ManyToManyField?

Good afternoon, I want to add a "similar objects" field, tobish:

class Picture(models.Model):
  ''' модель для картины (фильма, мультфильма, аниме)'''
        #похожие картины на текущую картину:
  similar_picture = models.ManyToManyField(Picture)


But I'm afraid it doesn't work like that)) How can this be implemented? I do not want to write a separate model)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-10-03
@bituke

similar_picture = models.ManyToManyField('self')
Relevant section of the documentation .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question