当前位置: 首页>>代码示例>>Python>>正文


Python manager.BaseManager类代码示例

本文整理汇总了Python中django.db.models.manager.BaseManager的典型用法代码示例。如果您正苦于以下问题:Python BaseManager类的具体用法?Python BaseManager怎么用?Python BaseManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BaseManager类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_manager_methods

    def test_manager_methods(self):
        """
        This test ensures that the correct set of methods from `QuerySet`
        are copied onto `Manager`.

        It's particularly useful to prevent accidentally leaking new methods
        into `Manager`. New `QuerySet` methods that should also be copied onto
        `Manager` will need to be added to `ManagerTest.QUERYSET_PROXY_METHODS`.
        """
        self.assertEqual(
            sorted(BaseManager._get_queryset_methods(QuerySet).keys()), sorted(self.QUERYSET_PROXY_METHODS)
        )
开发者ID:shellfly,项目名称:django,代码行数:12,代码来源:tests.py

示例2: __str__

    name = models.CharField(max_length=100)
    slug = models.SlugField()

    class Meta:
        ordering = ['name']

    def __str__(self):
        return self.name


class DoesNotExistQuerySet(QuerySet):
    def get(self, *args, **kwargs):
        raise Author.DoesNotExist


DoesNotExistBookManager = BaseManager.from_queryset(DoesNotExistQuerySet)


class Book(models.Model):
    name = models.CharField(max_length=300)
    slug = models.SlugField()
    pages = models.IntegerField()
    authors = models.ManyToManyField(Author)
    pubdate = models.DateField()

    objects = models.Manager()
    does_not_exist = DoesNotExistBookManager()

    class Meta:
        ordering = ['-pubdate']
开发者ID:CrazyChief,项目名称:django,代码行数:30,代码来源:models.py

示例3: get_manager

 def get_manager(cls):
     return type('DictManager', (BaseManager.from_queryset(cls)), {})
开发者ID:primal100,项目名称:django_easy_manager,代码行数:2,代码来源:queryset.py


注:本文中的django.db.models.manager.BaseManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。