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!
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4837fd8e-1193-48ba-a869-f233faf92443%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment