On 27 heinä, 18:50, Jeremy Dunck wrote:
> Ah, yes, hmm. Actually, it *is* possible to get signals attached to
> the through.
>
> from django.db.models import signals
> signals.pre_delete.connect(handler, sender=Voter.districts.through)
>
> So I don't think we can even take that shortcut on just t
On Thu, Jul 26, 2012 at 11:26 PM, Anssi Kääriäinen
wrote:
> On 27 heinä, 08:15, Jeremy Dunck wrote:
...
>> I would have expected something along the lines of :
>>
>> DELETE FROM `api_voter_districts` WHERE `voter_id` = 1
>>
>> But instead it's 2 queries:
>>
>> SELECT `api_voter_districts`.`id`, `
On 27 heinä, 08:15, Jeremy Dunck wrote:
> I have 2 models:
>
> class District(Model):
> pass
>
> class Voter(Model):
> districts = ManyToManyField(District)
>
> Sometimes I want to reset the m2m list:
>
> voter.districts = other_districts
>
> I noticed that this uses ManyRelatedManager._clear
I have 2 models:
class District(Model):
pass
class Voter(Model):
districts = ManyToManyField(District)
Sometimes I want to reset the m2m list:
voter.districts = other_districts
I noticed that this uses ManyRelatedManager._clear_items, which, among
other things, boils down to:
voter.distr