On Apr 22, 7:33 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Can you post the exact code throwing the error, and copy paste your
> exact model code related to the error?
The code is exactly the same as I wrote in my OP.
# models.py
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)
# test.py, this is used to retrieve author records of a particular
book.
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
>
> 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.
>
I am trying to get authors of a particular book, so
b = Book.objects.get(id=1) # Get some book
# Get the authors
for a in b.authors.all(): print a
However, as Jason mentioned below, it seems to be an unsolved bug. :(
-Ram
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---