I have this field
graduation_year = m.ForeignKey('GraduationYear', on_delete=m.SET_NULL, null=False,blank=False)
and GraduationYear
class is.
class GraduationYear(BaseModel):
label = m.CharField(max_length=255)
year = m.CharField(max_length=255,unique=True)
def __str__(self):
return self.label
Now I want to set the GraduationYear
object where year=2022 as the default value of graduation_year
So, I am guessing I should embed sql to here below.
graduation_year = m.ForeignKey('GraduationYear', on_delete=m.SET_NULL, null=False,blank=False,default='select GraduationYear where year=2022')
Is it possible?