Hi,

I have this code in myapp.intros.models to send a mail to the managers  
each time an intro gets saved:

from django.db.models.signals import post_save
from django.core.mail import mail_managers

def mail_on_create_intro(sender, **kwargs):
     if created:
         email_body = 'A new intro at ' + instance.url
         email_subject = 'New intro'
     else:
         email_body = 'An intro has changed at ' + instance.url
         email_subject = 'Changed Intro'
     mail_managers(email_subject, email_body)

post_save.connect(mail_on_create_intro, sender=Intro)

This doesn't work, here's the last part of the traceback:

  File "/home/benni/kassette/../kassette/intros/models.py", line 20,  
in mail_on_create_intro
    if created:

NameError: global name 'created' is not defined

How comes that?
The documentation at 
http://docs.djangoproject.com/en/dev/ref/signals/#post-save 
  says there should be an argument named 'created'...
If I replace 'created' with 'True' for example, the error says that  
'global name 'instance' is not defined'.

I suspect I'm writing bad syntax?

-benjamin


--~--~---------~--~----~------------~-------~--~----~
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