What you need is to keep your Education model as is (with no Lawyer Foreignkey) and add a ManyToManyField on your Lawyer class pointing to Education. Then you can go
Lawyer.objects.filter(education__school='...') I think that will solve your problem Greg 2009/11/9 Zeynel <azeyn...@gmail.com>: > > Hello, > > I decided to start my own project with what I learned from part 1 of > the tutorial. > > I have the project in C:\sw\sw\wkw > > The app sw.wkw is a prototype for a "who-knows-who" database for legal > profession. I wanted to start with a really simple model: > > class Lawyer(models.Model): > first = models.CharField(max_length=20) > initial = models.CharField(max_length=2) > last = models.CharField(max_length=20) > year_graduated = models.DateTimeField('Year graduated') > > class Education(models.Model): > # lawyer = models.ForeignKey(lawyer) > school = models.CharField(max_length=200) > > I commented out the ForeignKey because it caused an error. > > I will only make one search in the database. I want to enter Lawyer's > name and find all other lawyers in the database who graduated from the > same school the same year. It's like sorting by school in a > spreadsheet and pulling the lawyer's names. Here's the sample > spreadsheet: > > https://spreadsheets.google.com/ccc?key=0Al923jWh4O4ydG1vSmx4bDVqTUFUXzVqSXhzVkcydmc&hl=en > > Do you think this is the right model for what I am trying to do? Thank > you for your comments. > > So far I created the tables and tomorrow I'll set up the admin and > populate the database with some names. > > I am really enjoying Django. I am learning both Django and Python. > Thanks again for your help. > > > -- http://gregbrown.co.nz/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---