Hi all,
I'm migrating from django orm to sqlalchemy, in django was very simple
to override save method to do own stuff before save the value to
database, for example:
class TestModel(models.Model):
field1=models.CharField(max_length=255)
def save():
self.field1=self.field1.upper()
super(TestModel,self).save()
so when I add or modify an object it is ever converted to uppercase.
In sa this simple model become:
class TestModel(Base)
__tablename__='testtable'
field1=Column(Unicode(255))
def __init__(field1):
self.field1=field1.upper()
this way if I call the init method field1 is converted to upper but if
i modify the field I have to manually convert to upper. There is some
way to override save method as in django orm?
regards
drakkan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---