diff --git a/django/db/models/query.py b/django/db/models/query.py index 4e3326a9ca..365df96fb0 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -1089,6 +1089,12 @@ class EmptyQuerySet(QuerySet): """ return self + def update(self, **kwargs): + """ + Don't update anything. + """ + return 0 + # EmptyQuerySet is always an empty result in where-clauses (and similar # situations). value_annotation = False diff --git a/tests/modeltests/lookup/models.py b/tests/modeltests/lookup/models.py index 512ffd7e7d..72b547a376 100644 --- a/tests/modeltests/lookup/models.py +++ b/tests/modeltests/lookup/models.py @@ -295,6 +295,8 @@ DoesNotExist: Article matching query does not exist. [] >>> Article.objects.none().count() 0 +>>> Article.objects.none().update(headline="This should not take effect") +0 >>> [article for article in Article.objects.none().iterator()] []