models.Model.save(self)

super(ProjectModification, self).save()

On Jun 19, 1:41 pm, Adam Fraser <[EMAIL PROTECTED]> wrote:
> Signalling worked out for me but it turned out to be more complex than
> it needed to be.  Here are some references in case anyone is looking:
>
> http://www.chrisdpratt.com/2008/02/16/signals-in-django-stuff-thats-n...http://code.djangoproject.com/wiki/Signals
>
> In the end, I simply resolved to override the save() method of my
> Project class like so:
>
>     def save(self):
>         record_project_modification()
>         models.Model.save(self)
>
> ..here's the function that saves my new ProjectModification object:
>
>     def record_project_modification(self):
>         pmod = ProjectModification()
>         pmod.user_id = 21
>         pmod.project = self
>         pmod.date = datetime.date.today()
>         pmod.change_field = "test"
>         pmod.change_from =  "test"
>         pmod.change_to = "test"
>         pmod.save(pmod)
>
> ...I would have used the method mentioned in my first ref. above, but
> it turns out I couldn't have models importing signals while signals
> imported models.  Otherwise it would have made more sense for me to
> use signaling for scalability and elegance.
>
> -adam
>
> On Jun 18, 11:35 am, Adam Fraser <[EMAIL PROTECTED]> wrote:
>
> > I didn't, but you can bet I will now.  Thanks for the lead!
> > -Adam
>
> > On Jun 17, 4:22 pm, Dan <[EMAIL PROTECTED]> wrote:
>
> > > Did you take a look at Django Signals? You can intercept pre-save and
> > > post-save objects with them. You can use that to grab the data you
> > > want and fill your ProjectModification object. I don't know if there
> > > is a way you could tell if it was done in the admin or not though...
--~--~---------~--~----~------------~-------~--~----~
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