Re: Initialize model's fields

2010-09-16 Thread Marco Vicario
Thanks a lot Bruno!!! 2010/9/15 bruno desthuilliers > On 15 sep, 18:35, marcovic wrote: > > Hi all, > > i'm trying to do a simple task with Django but evidently it is not so > > simple... > > It is - when you understand how things work. > > > I have my model: > > > > class Mymodel(models.Model)

Re: Initialize model's fields

2010-09-15 Thread bruno desthuilliers
On 15 sep, 18:35, marcovic wrote: > Hi all, > i'm trying to do a simple task with Django but evidently it is not so > simple... It is - when you understand how things work. > I have my model: > > class Mymodel(models.Model): >     random_string = models.CharField(max_length=200) > >     def prod

Re: Initialize model's fields

2010-09-15 Thread ringemup
Your produce_string method is being run not just every time you create a new Mymodel, but every time you load an existing one from the database -- so it's overwriting your random strings on load. You'd probably do better producing the random strings in the save() method. On Sep 15, 12:35 pm, mar

Initialize model's fields

2010-09-15 Thread marcovic
Hi all, i'm trying to do a simple task with Django but evidently it is not so simple... I have my model: class Mymodel(models.Model): random_string = models.CharField(max_length=200) def produce_string(self): a = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "L", "M",