ForeignKey and *_set accessor method broke
|Reported by:||matthewharrison@…||Owned by:||adrian|
|Component:||Database layer (models, ORM)||Version:|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I revved to v3278 and my app broke. In my view I adjust some fields of the model.
My model looks something like this
class Foo(models.Model): name = models.CharField(maxlength=30) class Bar(model.Model): foo = models.ForeignKey(Foo) data = models.CharField(maxlength=30)
later on I iterate over my bars and try and get my foos from them. ie
for foo in bar.foo_set.all(): #do something with foo
I now get an attribute error when trying to do this:
AttributeError at /fooapp/ 'Bar' object has no attribute 'foo_set' Request Method: GET Request URL: http://localhost:8000/fooapp/ Exception Type: AttributeError Exception Value: 'Bar' object has no attribute 'foo_set'
Just wondering if there was a change that broke then _set functionality recently
I apologize for how vague this is. I have another model that has a foreign key and code similar to the above still works with that. I've briefly diffed the sources didn't chance on anything that looked to cause this change....
Change History (5)
comment:1 Changed 9 years ago by anonymous
- Resolution set to invalid
- Status changed from new to closed
comment:4 Changed 9 years ago by matt
- Resolution invalid deleted
- Status changed from closed to reopened