Skip to content

Commit 7f0fdb5

Browse files
committed
Improve documentation for delete_translations(). Closes #274, #275.
1 parent e08701d commit 7f0fdb5

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

docs/public/queryset.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,26 @@ delete_translations
9090

9191
.. method:: delete_translations()
9292

93-
Deletes all :term:`Translations Model` instances in a queryset, without
93+
Deletes all :term:`Translations Model` instances matched by a queryset, without
9494
deleting the :term:`Shared Model` instances.
9595

96+
This can be used to target specific translations of specific objects for deletion.
97+
For instance::
98+
99+
# Delete English translation of all objects that have field == "foo"
100+
MyModel.objects.language('en').filter(field='foo').delete_translations()
101+
102+
# Delete all translations but English for object with id 42
103+
MyModel.objects.language('all').exclude(language_code='en').filter(pk=42).delete_translations()
104+
105+
.. warning:: It is an error to delete all translations of an instance. This will
106+
cause the object to be unreachable through translation-aware queries
107+
and invisible in the admin panel.
108+
109+
If you delete all translations and re-create one immediately after,
110+
remember to enclose the whole process in a transaction to avoid
111+
the possibility of leaving the object unreachable.
112+
96113
.. _select_related-public:
97114

98115
select_related

0 commit comments

Comments
 (0)