On Wed, 2009-03-25 at 09:46 -0700, Jesse wrote:
> One research project can have many publications.  One model includes
> the research projects, one model includes the publications and a third
> model assigns multiple publications to each research project.
> The model:
> class Researchproject(models.Model):
>     restitle = models.TextField()
> 
> class Publication(models.Model):
>     pubtitle = models.TextField()
> 
> class Researchpublications(models.Model):
>     researchproject = models.ForeignKey(Researchproject)
>     publication = models.ForeignKey(Publication)
> 
> In the view.py the research projects are selected and appended into a
> list called:
> research_list
> 
> In the view I created this statement:
> respublications=Researchproject.objects.filter
> (researchpublications__researchproject=research_list), which doesn't
> get any errors, but also doesn't seem to do what I need it to do.

The problem here is in the filter constraint. The left-hand side of a
"thing=value" filter is talking about individual "things", so an
individual ResearchProject record in this case. That's a long way of
saying that you need to use the "__in" lookup type here:

        ....filter(researchpublications__researchproject__in=research_list)...

I think you'll find that will do what you're after. Right now (with your
current filter), not ResearchProject row will be equal to the list of
values on the right-hand side of the filter.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to