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?

Thanks,
Ram


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

Reply via email to