views:

34

answers:

3
obj = Info(name= sub,question=response_dict["question"])
obj.save()

After saving the data how to update another field of the same table

obj.err_flag=1
obj.update()//Will this work
+1  A: 

Just resave that instance:

obj.some_field = some_var
obj.save()

Django automatically knows when to UPDATE vs. INSERT your instance in the database.
This is explained in the Django docs.

Thanks...........
Hulk
+1  A: 
obj = Info(name=sub,question=response_dict["question"])
obj.save()

And then later you want to get it and update it (I'm assuming name is unique identifier):

obj = Info.objects.get(name=sub)
obj.err_flag=1
obj.save()
Brian Stoner
Thanks...........
Hulk
+1  A: 

If in the question you mean to say same object or same row where you say same table, then if you do this

obj = Info(name= sub,question=response_dict["question"])
obj.save()

and then after a few lines you need to do this

obj = Info.objects.get(name=sub)
obj.err_flag=1
obj.save()

then obj = Info.objects.get(name=sub) is unnecessary.

You simply do

obj = Info(name= sub,question=response_dict["question"])
obj.save()
#
#do what you want to do, check what you want to check
#
obj.err_flag=1
obj.save()
chefsmart
Thanks...........
Hulk