﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7368	Problem when overriding '__init__' / 'save' methods (models.model)	Eric	nobody	"In this sample model :

{{{
import logging

class Test(models.Model):
    title = models.CharField(max_length = 50)

    def __init__(self, *args, **kwargs):
        super(Test, self).__init__(*args, **kwargs)
        self.title = 'a_' + self.title
        logging.debug ('in_init : %s' % self.title)

    
    def save(self):
        logging.debug ('in_save : %s' % self.title)
        self.title = self.title[2:]
        logging.debug ('in_save2 : %s' % self.title)
        return super(Test, self).save()
    
    def __unicode__(self):
        return self.title
    
    class Admin:
        pass
}}}

The save fonction was called twice and so, the field 'title' does not contains the value without the 2 first characters 'a_' where add __init__.

Try this :

Add a 'test' row with title : 'This is a test'; saved; the list show 'a_This is a test', this is right at this moment. Edit it and without changing anything, hit 'Save and edit' button. 'a_' is append at the beginning of the title each time row was saved. Same problem with signals 'pre_save'.

If I try with she shell 'manager.py shell', no problems."		closed	Core (Other)	dev		worksforme			Unreviewed	0	0	0	0	0	0
