I'm writting 2 models with ManyToMany Relations, first I make a model to list all my requirements
class Requirements(models.Model):
requirement = models.CharField(max_length=150)
def __str__(self):
return self.requirement
So in this example my list of requirements will be:
- Personal ID
- Letter from your boss
- Last degree obtained
- Photography
Now I make custom list from different scenarios, since not all jobs require the same documents, my model will be:
class RequirementsList(models.Model):
job= models.ForeignKey(Jobs, on_delete=models.DO_NOTHING)
requirements= models.ManyToManyField(Requirements)
def __str__(self):
return str(self.job)
Now I can pick some of my requeriments and make custom lists from each job or position avaliable.
Last, I make my 3rd model , with a relation between RequirementList and File
class FileDetail(models.Model):
file= models.ForeignKey(File, on_delete=models.DO_NOTHING)
job = models.ForeignKey(Jobs, on_delete=models.DO_NOTHING, blank=True, null=True)
requeriments = models.ManyToManyField(RequirementsList)
def __str__(self):
return self.file
So I need my requirement list to filter what requirements who has to be in my file, but this only give to me in requirements a list of lists instead of requirements in the list.
I been reading the docs and found the "through" parameter but I can't make it work.
Somone has a clue of what I'm doing wrong?
Thanks!