Possible Duplicate:
(Django) Trim whitespaces from charField
In ruby on rails is really easy to strip spaces when saving a model. In django what's the best practice?
Possible Duplicate:
(Django) Trim whitespaces from charField
In ruby on rails is really easy to strip spaces when saving a model. In django what's the best practice?
It is very easy to override models.Model
save
method, to perform any pre svae actions. The link that stummjr
also provides an example.
class MyClass(models.Model):
# some fields here
def save(self, *args, **kwargs):
# strip spaces here
super(MyClass, self).save(*args, **kwargs)
# make sure to call parent save method ^