我需要一个与最多3项数据(同类数据)相联系的模式。
Here is an example:
I have candidates that need to pass 3 steps to be recruited
class Candidate(models.Model):
user = models.ForeignKey(User)
step1 = models.TextField(blank=True, null=True,)
step2 = models.TextField(blank=True, null=True,)
step3 = models.TextField(blank=True, null=True,)
每个步骤都由若干人进行审查。
class Review(models.Model):
candidate = models.ForeignKey(Candidate)
reviewer = models.ForeignKey(User)
step1 = models.TextField(blank=True, null=True,)
step2 = models.TextField(blank=True, null=True,)
step3 = models.TextField(blank=True, null=True,)
- Should I factorize these objects which would give me 4 objects instead of 2
such asCandidate
,Review
,CandidateStep
andReviewStep
?
- If yes, how can I limit to 3 steps ?
- If not, how can easily iterate through the steps ?
www.un.org/Depts/DGACM/index_spanish.htm 例数据:
obj, created = Candidate.objects.get_or_create(
user = SelectedCandidate
, defaults = { step1 : , step2 : , step3 : }
)
obj.step1 = I m really motivated
obj.step2 = I m able to do this job
obj.save()
obj, created = Review.objects.get_or_create(
user = request.user
, defaults = { step1 : , step2 : , step3 : }
)
obj.step1 = He seems over motivated
obj.save()