models.py
:
class ReviewString(models.Model):
REVIEW_TYPES = (
('bad', 'bad'),
('ok', 'ok'),
('good', 'good')
)
review_type = models.CharField(max_length=50, choices=REVIEW_TYPES)
# other fields here
class ReviewInteger(models.Model):
REVIEW_TYPES = (
('bad', -1),
('ok', 0),
('good', 1)
)
review_type = models.IntegerField(choices=REVIEW_TYPES)
# other fields here
两个表 (ReviewString
和ReviewInteger
) 在数据库中都包含相同的数据。我想知道,这两个字符串之间是否有任何性能差异:
ReviewString.objects.filter(review_type='ok')
ReviewInteger.objects.filter(review_type=0)
那么,我应该使用ReviewString
orReviewInteger
吗?