#1796: [patch] "Cannot resolve keyword ___ into field" error when working with
ManyToMany relation
-------------------------+--------------------------------------------------
Reporter: anonymous | Owner: mtredinnick
Status: reopened | Component: Database wrapper
Version: SVN | Resolution:
Keywords: | Stage: Accepted
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------+--------------------------------------------------
Comment (by anonymous):
Replying to [comment:75 brantley <[EMAIL PROTECTED]>]:
> I'm not sure where everyone is on this but I figured it out for me so I
thought I'd share:
>
> The problem is that the get_all_related_many_to_many_objects() caches
itself, so if the many-to-many manager gets called before all the apps are
loaded, any models in apps added afterwards won't be in that cache. I
commented out the line that gets the cache so it has to re-cache each
time, and it fixes the problem. Behold:
>
> {{{
> def get_all_related_many_to_many_objects(self):
> try: # Try the cache first.
> return self.ham_sandwich
> #return self._all_related_many_to_many_objects
> except AttributeError:
> ...
> }}}
>
> Since .ham_sandwich is never found it falls into the AttributeError
exception and re-caches. It then works as planned.
>
> The permanent fix, it seems to me, is to make it so that when a many-to-
many is created, it clears the _all_related_many_to_many_objects of the
_meta of the relation class, but I'm not sure exactly where best to do
that.
An FYI...this suggested fix did not work for me.
--
Ticket URL: <http://code.djangoproject.com/ticket/1796#comment:78>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---