I have two identical models, let's say X and Y in django like this:
class X(models.Model):
con = models.CharField(max_length=100)
a = models.ForeignField("FOO")
class Y(models.Model):
con = models.CharField(max_length=100)
b = models.ForeignField("BAR")
To access an object of these models, I have to use the following code:
models.X.objects.get(
con = "something",
a = xy
)
models.Y.objects.get(
con = "something",
b = yx
)
Is there a way to set the model name as variable such as model_name = X
and then use this code to access the objects:
models.model_name.objects.get(**my_dict)
where
my_dict = {"con":"something", "a":xy}