> Thanks. Any idea why the following isn't working in my News class? > The processing doesn't get to that exit call, even if it's a new item. > > def save(self, *args, **kwargs): > if not hasattr(self,'id'): > import sys > sys.exit('must be a new item') > super(News, self).save(*args, **kwargs)
hasattr doesn't work in this situation, or I'm not using it right. In any case, the following works: def save(self, *args, **kwargs): if not self.id: import sys sys.exit('a new item') super(News, self).save(*args, **kwargs) -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.