Remarkably, I've just today tripped over this same exact
problem again. Turns out even using a post_save signal
callback function does not provide the information about
the new M2M data.
# callback for post_save signal, debug code removed for brevity
def ldap_netgroup_save(sender, **kwargs):
Hallöchen!
Jeff writes:
> [...]
>
> I found the 'm2m_changed' signal yesterday, read that you can't
> determine *what* changed by using it, and also ended up directed
> to some open bug reports... etc... and threw up my hands.
But the "action" and "pk_set" arguments contain this information.
Ts
The only other way that I could think to do it would be to write your own
M2M object. Just an object with two foreign key fields to reference X and
Y. In that object you could overwrite the save method to check for which
relations currently exist for a given reference to X and update
accordingly. I
On Jan 11, 9:23 pm, Dennis Lee Bieber wrote:
> On Wed, 11 Jan 2012 17:26:44 +, Tom Evans
> wrote:
>
> >On Wed, Jan 11, 2012 at 5:22 PM, Jeff wrote:
> >> When Device.netgroups (a M2M field) changes, we need to perform
> >> some python-ldap operations.
>
> >Have you considered simply going ba
I've just found that the problem is related to my desired
field being M2M. Anyone know what is going on here? :(
My approach (and Matt's) works fine on a simple CharField field.
class Device(models.Model):
# ...
floor = models.CharField('Floor', max_length=10, blank=True)
# ...
Devi
> But is costly when the field in question is foreign, no? Mine's a
M2M.
Sure. There's probably no way around that, though, except for
judicious use of select_related.
https://docs.djangoproject.com/en/dev/ref/models/querysets/#select-related
--
You received this message because you are subsc
On Wed, Jan 11, 2012 at 5:22 PM, Jeff wrote:
> When Device.netgroups (a M2M field) changes, we need to perform
> some python-ldap operations.
Have you considered simply going back to the database to check what
the values currently are? It would be inefficient, but clean and
concise.
Cheers
Tom
On Jan 11, 11:59 am, Andre Terra wrote:
> The important question here is, what are you trying to achieve, outside of
> the functionality itself? Are you trying to log changes to provide an audit
> trail? If so, there are tools for that.
I wish that's all I was doing. Then again, I also wish Goog
The important question here is, what are you trying to achieve, outside of
the functionality itself? Are you trying to log changes to provide an audit
trail? If so, there are tools for that.
Cheers,
AT
On Wed, Jan 11, 2012 at 2:53 PM, Jeff wrote:
> Matt,
>
> On Jan 10, 5:57 pm, Matt Schinckel
On Jan 11, 10:03 am, "hanks...@gmail.com" wrote:
> I go about this a different way, which is to monkeypatch the object
> with the relevant initial values at __init__:
>
> https://gist.github.com/1595055
>
> Saves you a database call.
But is costly when the field in question is foreign, no? Mine'
Matt,
On Jan 10, 5:57 pm, Matt Schinckel wrote:
> The way I generally do this type of thing
> is:https://gist.github.com/1591723
Thanks for the reply!
This looked awfully similar to my logic (although yours is 10x more
clean),
but I was excited to implement it this morning. After doing so, I a
I go about this a different way, which is to monkeypatch the object
with the relevant initial values at __init__:
https://gist.github.com/1595055
Saves you a database call.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group,
The way I generally do this type of thing
is: https://gist.github.com/1591723
Lately, I've been using model validation: the clean() method instead of the
save() method, but I can't remember if this is always called.
https://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objects
Sigh. I hate Google Groups via web. Here is a readable version of
the .save() method below.
https://gist.github.com/1591028
On Jan 10, 3:15 pm, Jeff wrote:
> For example, altering 'pana.our.org''s netgroups field, the following
> save() method results in this debug line which makes no sense to
For example, altering 'pana.our.org''s netgroups field, the following
save() method results in this debug line which makes no sense to me:
CHANGED: Device pana.our.org had old netgroups [{'name':
u'testnetgroup', 'desc': u''}] and now has new netgroups [{'name':
u'testnetgroup', 'desc': u''}]
On Jan 10, 10:42 am, Kelly Nicholes wrote:
> Isn't there a form.changed_data ?
See 1st post below indicating we manipulate Django data from various
Django
codebases, not just a web form.
> > I need to.. ... How
> > can I do this,
> > beari
On Jan 10, 10:09 am, Nahuel Defossé wrote:
> I think you should see at the forms's cleaned_data attribute and
> compare it against the model current state, before saving.
As I indicated in the 1st post:
> >> > I need to ... ...
> >> > How c
Isn't there a form.changed_data ?
On Jan 9, 6:39 pm, Jeff wrote:
> Hi all,
>
> I need to be able to determine, at .save() time (before I call the
> parent class' .save()), if a certain field on my model object was
> changed, and act on that via some custom code. How can I do this,
> bearing in m
Hi,
I think you should see at the forms's cleaned_data attribute and
compare it against the model current state, before saving.
Regards
Nahuel
2012/1/10 Jeff :
> On Jan 10, 8:14 am, Andre Terra wrote:
>> You can override the model's save method?[1][2]
>
> Hi Andre,
>
> Thanks for replying. Yes,
On Jan 10, 8:14 am, Andre Terra wrote:
> You can override the model's save method?[1][2]
Hi Andre,
Thanks for replying. Yes, I'm aware that I need to override .save().
See:
> > I need to be able to determine, at .save() time (before I call the
> > parent class' .save()), ...
I need to know ho
You can override the model's save method?[1][2]
Cheers,
AT
[1]
https://docs.djangoproject.com/en/dev/ref/models/instances/#saving-objects
[2]
https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-model-methods
On Mon, Jan 9, 2012 at 11:39 PM, Jeff wrote:
> Hi all,
>
> I need to
21 matches
Mail list logo