mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #10506, #13793, #14891, #25201 -- Introduced new APIs to specify models' default and base managers.
This deprecates use_for_related_fields.
Old API:
class CustomManager(models.Model):
use_for_related_fields = True
class Model(models.Model):
custom_manager = CustomManager()
New API:
class Model(models.Model):
custom_manager = CustomManager()
class Meta:
base_manager_name = 'custom_manager'
Refs #20932, #25897.
Thanks Carl Meyer for the guidance throughout this work.
Thanks Tim Graham for writing the docs.
This commit is contained in:
@@ -85,6 +85,8 @@ class StatusPerson(MyPerson):
|
||||
"""
|
||||
status = models.CharField(max_length=80)
|
||||
|
||||
objects = models.Manager()
|
||||
|
||||
# We can even have proxies of proxies (and subclass of those).
|
||||
|
||||
|
||||
@@ -96,6 +98,8 @@ class MyPersonProxy(MyPerson):
|
||||
class LowerStatusPerson(MyPersonProxy):
|
||||
status = models.CharField(max_length=80)
|
||||
|
||||
objects = models.Manager()
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class User(models.Model):
|
||||
|
||||
Reference in New Issue
Block a user