The docs talk about models here: http://docs.djangoproject.com/en/dev/topics/db/models/ foreign keys here: http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey and queries here: http://docs.djangoproject.com/en/dev/topics/db/queries/#retrieving-objects
This advice isn't tested, so it might have syntax issues: Basically, assuming you have a models.py file roughly like this: from django.db import models class Book(models.Model): title = models.CharField(max_length=100) class Phrase(models.Model) text = models.CharField(max_length=100) book = models.ForeignKey('Book') Then you could get that data like this: title = "The book's title" book = Book.objects.get(title=title) phrase = Phrase.objects.get(book=book) Now you have all the objects you need, just access their data like normal python objects. book.title phrase.text HTH! Alex On Mar 16, 9:01 am, Norman <n.rosi...@gmail.com> wrote: > How to perform such simple query: > > select p.text, b.title from books b, phrase p where p.book_id = b.id > > on tables > > books{ > id : int, > title: varchar > > } > > phrase{ > id : int, > book_id : int, > text: varchar > > } > > but using django models? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---