我目前正在努力在Django中实现评论应用。 在此评论应用程序的models.py中:
from salon.models import salon
from services.models import Service
from packages.models import Packages
MODEL_OBJECTS = (
('salon':salon),
('service':Service),
('package':Packages),
)
class Reviews(models.MODEL):
user = models.ForeignKey(User, verbose_name=_("user"), on_delete=models.CASCADE)
comment = models.TextField(_("User Comment"))
rating = models.IntegerRangeField(min_value=1, max_value=5, blank=True)
rate_object = models.CharField(_("Model Choice") choices=MODEL_OBJECTS,default='salon')
rate_object_id = models.IntegerField(_("rate_object_id"))
我希望 rate_object 包含要对其进行评级的模型,并且 rate_object_id 包含在 rate_object 中选择的模型的实例ID
我无法考虑实现此目标。任何帮助都会有所帮助,谢谢