L
L
lleviy2019-11-23 17:16:44
Django
lleviy, 2019-11-23 17:16:44

How to select from django images?

I have a model - Topic. I want that when creating an object of this model in an auto-generated form, in addition to the name and text, 5 pictures are displayed. The user could click on the picture, thereby assigning the desired image to the created topic.
I just can’t figure out how to do this, there is a clause in the documentation about the possibility of making a selection like this:

CHOICES = (
        ('choice1', 'choice1'),
        ('choice2', 'choice2'),
    )

But this applies to text, not images.
If this is not possible to implement in the model, please tell me how can I do it outside the model? I had an idea to make a separate form with a selection, which would then pass the value of the model, but again - I can't figure out how to do it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question