diff --git a/tutorial.py b/tutorial.py index 8e2eb5e..7b2cb6c 100644 --- a/tutorial.py +++ b/tutorial.py @@ -108,11 +108,10 @@ class GalateaTutorial(ModelSQL, ModelView): 'image_size': ('Thumb "%(file_name)s" size is larger than "%(size)s"Kb'), }) + @fields.depends('name', 'slug') def on_change_name(self): - res = {} if self.name and not self.slug: - res['slug'] = slugify(self.name) - return res + self.slug = slugify(self.name) @classmethod def write(cls, *args):