In a many-to-one relationship (ie reverse of ForeignKey), an instance
has a related manager that (apparently) caches its relatees, at least
in some circumstances. Is it possible to clear this cache?

This would be useful in the following scenario:

class Foo( Model ):
    pass

class Bar( Model ):
    foo = ForeignKey( Foo, related_name = 'bars' )

while changing a certain Foo (I already have a "dirty" copy of it), I
notice I want to delete a Bar it contains. Then I want to call a
member function on Foo -- say one that keeps stats on it Bars it
contains.

If I call it without doing anything, it seems to think the Bar I
deleted still exists. I can't call Foo.bars.remove( ... ) because
Bar.foo doesn't have "null = True" specified.

As a work around, I guess I could save my dirty Foo to the database,
then get a clean copy. (Fortunately, I'm using per-view transactions).
But this is obviously messy; I don't think I should have to save my
dirty object at all, and I should still be able to tell it about the
missing Bar.

Thanks for any advice,
- Shaun


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