On Oct 12, 1:04 pm, Adam Endicott <[EMAIL PROTECTED]> wrote:
> > How about something along these lines (a lazy initialization pattern):
>
> Well, the point of saving that boolean was so I could do database
> queries on it (MyModel.objects.filter(has_m2m_thing=True)). That
> wouldn't really work with this lazy initialization pattern, unless I'm
> missing something.
No, you're right -- that won't work.
> Sorry, I guess I should have mentioned that.
No problem. I had assumed that you needed the boolean in a template or
a view.
I don't think there's a clean solution to this (as far as making the
Admin work with it). I don't think the admin can make use of a custom
manipulator without hackish code.
If you are open to patching Django itself, you could add a custom
signal to django.db.models.manipulators.AutomaticManipulator.save() to
transmit a "post_full_save" signal at the very end of that method
call. That would give you the appropriate hook you need.
Another idea is to use a database trigger on the m2m table to update
the count/boolean field on the parent table.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---