I want to delete a record. But I of a particular record. Such as
delete from table_name where id = 1;
How can I do this in a django model?
I am writing a function:
def delete(id):`
-----------
I want to delete a record. But I of a particular record. Such as
delete from table_name where id = 1;
How can I do this in a django model?
I am writing a function:
def delete(id):`
-----------
There are a couple of ways:
To delete it directly:
SomeModel.objects.filter(id=id).delete()
To delete it from an instance:
instance = SomeModel.objects.get(id=id)
instance.delete()