James Matthews wrote:
> I have three tables:
>
> class Technology(models.Model):
> technology = models.CharField(max_length=100, null=True,
> blank=True )
> def __unicode__(self):
> return self.technology
> class Meta:
> ordering = ["technology"]
>
> class Publication(models.Model):
> pubtitle = models.TextField(null=True, blank=True)
> def __unicode__(self):
> return self.pubtitle
> class Meta:
> ordering = ["pubtitle"]
>
> class Techpubcombo(models.Model):
> technology = models.ForeignKey(Technology)
> publication = models.ForeignKey(Publication)
>
> The user selects a technology from the drop down menu on the web
> page. The technology is retrieved
> from the database table and then it must be used to retrieve the
> publication attributes, by first going through the Techpubcombo table.
>
> I wrote the select to retrieve the data for the html drop down box:
> technology_list = Technology.objects.all().order_by('technology')
>
> After the user makes a selection, the technology_id is retrieved:
> technology_id = request.POST['technology_id']
> t = get_object_or_404(Technology, pk=technology_id)
>
> Now I need to use the technology_id to get to the publication
> attributes
>
> This is where I'm stuck.
>
> I get error messages when I try to do something like:
>
> pub=t.techpubcombo.publications_set()
I believe this would work:
publications = Publication.objects.filter(techpubcombo__technology=t)
Regards,
--
Christian Joergensen
http://www.technobabble.dk
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---