Tuesday, 15 July 2014

python - How to add value to a column in a record which is already saved in django -


I am trying to save a data to a column, but this record is already saved. I am using Django and SQL

Models.py

  I am working with class P. (models.Model): T = Model Forininki (T) Q = Model Textfield (max_lamp  

... P_object = P (t_id = T_object.id, q = q) P_object.save () ...

I'm saving only two columns here and I want to save the third column later on separately when I get an ID from any other record

 < Code> A_object = A (q_id = q_object.id, a = a) A_object.save () P_object.c_a = A_object .id   

but this code does not seem to work. I am doing it wrong?

"does not seem to work "The description of a problem can be useless. You have got the first two points (" What do I do here, "" what I hope here ") is fine, but you are one of the third part: Here's what I find ". But anyway ...

  A_object = A (q_id = q_object.id, a = a) A_object.save () P_object.c_a = A_object.id < Examples of model / code>  

are not saved automatically when saved, so you have to save them by yourself. Just add

  P_object.save ()   

and you should be ok otherwise else please post the entire traceback.

On the one hand, for any reason, you do not use the model. Fields instead of fields?

No comments:

Post a Comment