Re: Question about post_save

2014-08-14 Thread Collin Anderson
@receiver(models.signals.post_save, sender=Cars)
def auto_num_on_save(sender, instance, **kwargs):
if hasattr(instance, '_already_ran'):
return
my code
instance._already_ran = True
instance.save()



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/529c9c29-7e38-4a73-a0b8-8f299a4c1073%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Question about post_save

2014-08-14 Thread Johannes Schneider
Is there any reason why this has to happen after saving? otherwise you 
could use pre_save.


bg,
Johannes

On 14.08.2014 08:12, Neto wrote:

I'm using post_save but he is in loop:

@receiver(models.signals.post_save, sender=Cars)
def auto_num_on_save(sender, instance, **kwargs):
 my code
 instance.save()


How do I save changes without calling post_save again?

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/91745299-16fe-477a-b532-f2580e806d91%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.



--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/53EC6206.7040903%40galileo-press.de.
For more options, visit https://groups.google.com/d/optout.


Question about post_save

2014-08-14 Thread Neto
I'm using post_save but he is in loop:

@receiver(models.signals.post_save, sender=Cars)
def auto_num_on_save(sender, instance, **kwargs):
my code
instance.save()


How do I save changes without calling post_save again?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/91745299-16fe-477a-b532-f2580e806d91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.