开发者

Object has no attribute 'prepare'

In my django project, I have 4 models that are all tied together in a chain.

Model_D > Model_C > Model_B > Model_A

So Model_C has a foreign key field that points to Model_B, and Model_B has a foreign key field that points to Model_A

When I do a lookup like below, I get the following error

Model_D.objects.filter(model_c = object_of_type_c)

I get the error "Model_C has no attribute 'prepare'"

But, when I do the lookup like this, I get no error

Model_D.objects.filter(model_c__id = object_of_type_c.id)

or

Model_D.objects.filter(model_c = object_of_type_c.id)

I can't even seem to find this error searching here or google. I think it has something to do with how the related objects manager works but I'm stuck.

EDIT: There is a 5th model, Model_E which is also tied to Model_C. I get the same problem when trying to a lookup on this model as well. I don't know if this makes any difference.

The weirdest part is that it seems to work fine for doing similar lookups for Model_C, or Model_B.

UPDATE:

http://code.djangoproject.com/ticket/13640

Model_C has a method named 'evaluate' which is a reserved name. Fixes the problem by renamin开发者_开发知识库g the method.

I have tried adjusting the related_name values for these models in a number of ways and haven't had any success there either.


http://code.djangoproject.com/ticket/13640

This error arises when you define a method on a model with the name 'evaluate'. Renaming the method solves the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜