Example code:

def save(self):
        regex = re.compile("\{\{([^\}]{2,60})\}\}")
        words = regex.findall(self.body)
        self.body = regex.sub("\\1",self.body)
        super(Chapter,self).save()
        for word in words:
                if len(word.strip()) > 0:
                        try:
                                self.keywords.create(value=word.strip().title())
                        except Exception, e:
                                print e
        print self.keywords.all() # This prints the correct keywords!
        super(Chapter,self).save()


The outcome of this code is that new Keywords are created, but they
are not bound to this Chapter.
Simply calling chapter.keywords.create(value="Test") will indeed
create a new keyword with the value "Test" bound to the chapter. I am
running this from the django admin btw.

The problem seems to be in the
django.db.models.fields.related._add_items method, somewhere around
line 340.
The fact is that the insertion query is executed, but for some reason
it is not committed, perhaps it is a transaction issue?

It is simply broken when called from within the save() method of a
Model instance...

I haven't started a ticket because I am not sure if this is bug or a
feature ;-)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to