R
R
rumak2018-07-18 13:24:20
Django
rumak, 2018-07-18 13:24:20

How to implement choice in a model that contains values ​​from another model?

Let's say we have this class:

class One(models.Model):
    field = models.CharField(max_length=30)

And there is a second class:
class Two(models.Model):
    choices = *здесь должна быть ссылка на поле "field" класса "One"*
    field_choice = models.CharField(choice=choices)

There was a need to make "choice" contain the contents of the "field" field of the "One" class with the ability to select before publishing several such "fields" with different "id". Is it possible to do this with standard Django tools?
I would be very grateful for any answers!

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