我正在做一个工作门户,我需要使用VacancyApply模型访问Vacancy模型的用户字段。
model.py
class Vacancy(models.Model):
user=models.ForeignKey(User,on_delete=models.CASCADE)
jobcategory=models.IntegerField(choices=(
(1,'IT/Telecomunication'),
(2,'Engineering'),
(3,'Medical'),
))
title=models.CharField(max_length=50)
date_added=models.DateTimeField(auto_now_add=True)
updated_on=models.DateTimeField(auto_now=True)
deadline=models.DateField(default=datetime.now() + timedelta(days=15))
description=RichTextField()
def __str__(self):
return(self.title)
class VacancyApply(models.Model):
user=models.ForeignKey(User,on_delete=models.CASCADE)
vacancy=models.ForeignKey(Vacancy,on_delete=models.CASCADE)
applieddate=models.DateField(auto_now=True)
status=models.IntegerField(choices=status_choices,default=1)