python sql query in django
May
adleslie at gmail.com
Mon Feb 23 14:17:42 EST 2009
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
More information about the Python-list
mailing list