--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Hi,How about telling us what are you trying to achieve by comparing to previous state of the object?
class MyPublicationModel(Model):def save(...): # I don't remember the signatureif self.is_published and not self.publication_date:# Published previously unpublished - set the dateself.publication_date = date.today()elif not self.is_published and self.publication_date:# Mark already published as unpublished - clear the dateself.publication_date = Nonesuper(self, MyPublicationModel).save(...)
This is a long shot but try checking out django-reversion
thank you.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/NM39pkUyvG4J.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
uhm, if you register a listener to the pre_save signal, then you can do this:
if instance.published:
# the instance about to be saved has the published flag on
dbojb = MyModel.objects.get(id=instance.id)
# did it have it on the database?
if not dbobj.published:
do_stuff()
you probably need to check the "created" argument on the listener that tells you if the object is a new one, or a modification
--
"The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde
|_|0|_|
|_|_|0|
|0|0|0|
(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.