mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-16 20:00:23 +00:00
Remove out-to-date example
This commit is contained in:
parent
ced4afe8f9
commit
7552c4a7f2
1 changed files with 3 additions and 28 deletions
|
|
@ -128,33 +128,8 @@ Mixins
|
|||
------
|
||||
|
||||
Each of the above manager classes has a corresponding mixin that can be used to
|
||||
add functionality to any manager. For example, to create a GeoDjango
|
||||
``GeoManager`` that includes "soft deletable" functionality, you can write the
|
||||
following code:
|
||||
add functionality to any manager.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from django.contrib.gis.db import models
|
||||
from django.contrib.gis.db.models.query import GeoQuerySet
|
||||
|
||||
from model_utils.managers import SoftDeletableManagerMixin
|
||||
|
||||
class SoftDeletableGeoManager(SoftDeletableManagerMixin, models.GeoManager):
|
||||
pass
|
||||
|
||||
class Location(SoftDeletableModel):
|
||||
public = models.BooleanField(default=True)
|
||||
objects = SoftDeletableGeoManager()
|
||||
|
||||
# This delete will be a "soft" delete
|
||||
Location.objects.delete()
|
||||
|
||||
|
||||
Now you have a "soft delete manager" that can also take advantage of
|
||||
GeoDjango's spatial lookups. You can similarly add additional functionality to
|
||||
any manager by composing that manager with ``InheritanceManagerMixin`` or
|
||||
``QueryManagerMixin``.
|
||||
|
||||
(Note that any manager class using ``InheritanceManagerMixin`` must return a
|
||||
Note that any manager class using ``InheritanceManagerMixin`` must return a
|
||||
``QuerySet`` class using ``InheritanceQuerySetMixin`` from its ``get_queryset``
|
||||
method.)
|
||||
method.
|
||||
|
|
|
|||
Loading…
Reference in a new issue