定义我的模型
class Model1(models.Model):
description = models.TextField()
some_attribute_1 = models.IntegerField
class Model2(models.Model):
description = models.TextField()
some_attribute_2 = models.CharField(max_length=10)
我想构建一个函数:
def my_function(model, desc):
return model.objects.filter(description = desc)
并将其用作
str1 = my_function(Model1, "some description")
str2 = my_function(Model2, "some description")