FWIW, I just submitted a patch which makes that error message more helpful by showing the list of valid fields: http://code.djangoproject.com/ticket/4130
--Ned. [EMAIL PROTECTED] wrote: > Can you post the exact code throwing the error, and copy paste your > exact model code related to the error? > > It sounds like you have something like the following: > > .filter(book= > > where it should be something like > > .filter(someobject__book > > But it's hard to tell w/out seeing the code. > > On Apr 22, 12:59 am, Ramashish Baranwal <[EMAIL PROTECTED]> > wrote: > >> On Apr 22, 3:13 am, Ramashish Baranwal <[EMAIL PROTECTED]> >> wrote: >> >> >> >> >>> Hi, >>> >>> I using a script to fetch some database records. However, when it >>> encounters a ManyToManyField it gives the following error- >>> >>> TypeError: Cannot resolve keyword 'book' into field >>> >>> My models.py looks like this- >>> >>> from django.db import models >>> >>> # Create your models here. >>> class Author(models.Model): >>> name = models.CharField(maxlength=100) >>> >>> class Book(models.Model): >>> title = models.CharField(maxlength=100) >>> authors = models.ManyToManyField(Author) >>> >>> and my test script to retrieve records contains (the app name is >>> test)- >>> >>> import os >>> if not os.environ.has_key('DJANGO_SETTINGS_MODULE'): >>> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' >>> >>> import settings >>> from test.models import * >>> >>> b = Book.objects.get(id=1) >>> for a in b.authors.all(): print a >>> >>> I am using django with sqlite2 on Fedora Core 6 with python-2.4.3 and >>> have tried version 0.95, 0.96 and svn trunk. All throw the same error- >>> TypeError: Cannot resolve keyword 'book' into field >>> When I try the same through "python manage.py shell" interactive >>> shell, i.e. by entering the two lines above, it works fine. Probably, >>> I'm missing some setting option. But the same script works for models >>> that don't contain an M2M field, so that seems unlikely. >>> >>> Any clues? >>> >> Sorry, a typo in my earlier post. Its sqlite3 not sqlite2. >> >> Ram >> > > > > > > > > > -- Ned Batchelder, http://nedbatchelder.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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---