django - update an object after deleting a value from it -
i have object productobj
. when iterating through object if particular condition met have delete value object.
something like
for data in productobj: if data.count > 0: data.delete()
if count greater 0 data value should deleted , productobj
should updated.
just working off own code, then
if data.count > 0: data.count = none #continue stuff , lastly call .save() productobj.save()
should suffice.
calling .delete()
will, in django, remove entire object.
however if want delete attribute of said object, you're gonna have bad time, when you're working of object inherits models.model
let's go ahead , anyways
del productobj.count #from object
and if want stripped model have delete models _meta
fields property -> model._meta.fields
daniel roseman explains brilliantly here
Comments
Post a Comment