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()
More Related Contents:
- How do I filter query objects by date range in Django?
- Django Aggregation: Summation of Multiplication of two fields
- Getting the SQL from a Django QuerySet [duplicate]
- How do I do a not equal in Django queryset filtering?
- LEFT JOIN Django ORM
- Django values_list vs values
- “_set” in a queryset object in Django
- Count number of records by date in Django
- How to perform OR condition in django queryset?
- What is the best way to access stored procedures in Django’s ORM
- QuerySet, Object has no attribute id – Django
- Get the latest record with filter in Django
- Django filter JSONField list of dicts
- Can a dictionary be passed to django models on create?
- Django dynamic model fields
- Django filter queryset __in for *every* item in list
- How to create an object for a Django model with a many to many field?
- django abstract models versus regular inheritance
- Getting TypeError: __init__() missing 1 required positional argument: ‘on_delete’ when trying to add parent table after child table with entries
- Get all related Django model objects
- Django Rest Framework and JSONField
- Writing a __init__ function to be used in django model
- aggregate() vs annotate() in Django
- Count() vs len() on a Django QuerySet
- Customize/remove Django select box blank option
- Duplicating model instances and their related objects in Django / Algorithm for recusrively duplicating an object
- Identify the changed fields in django post_save signal
- Django 2.1.3 Error: __init__() takes 1 positional argument but 2 were given
- How to quote a string value explicitly (Python DB API/Psycopg2)
- Django foreign key relation in template