---------- Forwarded message ----------
From: May <adles...@gmail.com>
Date: Mon, Feb 23, 2009 at 9:17 PM
Subject: python sql query in django
To: python-l...@python.org


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()

Ana
--
http://mail.python.org/mailman/listinfo/python-list



-- 
http://www.goldwatches.com/

http://www.jewelerslounge.com/

--~--~---------~--~----~------------~-------~--~----~
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