Hello: I'm having a problem trying to convert something that works great on the python interpreter into the model.
I need to set a property of a model before it is saved. This propery is dependent on the primary key (serial) of the record. I tried first to do it using _post_save() but the id value was 'None'. So when I put it _pre_save() I need to get the next id in the sequence. At the python prompt, I can get the current max id using: >>> from django.models.backend import workorders >>> workorders.get_values(fields=['id'])[-1:][0]['id'] 9 I need to get the same number in the model, which I tried using: def _pre_save(self): lastid = self.get_values(fields=['id'])[-1:][0]['id'] self.wonum = 'WO-'+lastid+1 I get the following error. 'WorkOrder' object has not attribute 'get_values'. Any ideas? Regards, Burhan