L
L
lite_version2022-02-23 14:16:04
Django
lite_version, 2022-02-23 14:16:04

Is it possible to make a variable ForeignKey in a model?

Is it possible in Django to create a variable field that will store the key (chain) when there is data in another model?
As an example:

class Base(models.Model):
    ...
    data = ForeignKey('One' or 'Two')

class One(models.Model):
    ...
class Two(models.Model):
    ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Nesterov, 2022-02-23
@lite_version

closest contenttypes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question