當前位置: 首頁>>代碼示例>>Python>>正文


Python models.ForeignKeyTarget類代碼示例

本文整理匯總了Python中tests.models.ForeignKeyTarget的典型用法代碼示例。如果您正苦於以下問題:Python ForeignKeyTarget類的具體用法?Python ForeignKeyTarget怎麽用?Python ForeignKeyTarget使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ForeignKeyTarget類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

 def setUp(self):
     target = ForeignKeyTarget(name='target-1')
     target.save()
     for idx in range(1, 4):
         if idx == 3:
             target = None
         source = NullableForeignKeySource(name='source-%d' % idx, target=target)
         source.save()
開發者ID:Ian-Foote,項目名稱:django-rest-framework,代碼行數:8,代碼來源:test_relations_slug.py

示例2: test_queryset_size_with_Q_limited_choices

    def test_queryset_size_with_Q_limited_choices(self):
        limited_target = ForeignKeyTarget(name="limited-target")
        limited_target.save()

        class QLimitedChoicesSerializer(serializers.ModelSerializer):
            class Meta:
                model = ForeignKeySourceWithQLimitedChoices
                fields = ("id", "target")

        queryset = QLimitedChoicesSerializer().fields["target"].get_queryset()
        assert len(queryset) == 1
開發者ID:rsalmaso,項目名稱:django-rest-framework,代碼行數:11,代碼來源:test_relations_pk.py

示例3: setUp

    def setUp(self):
        """
        Create 3 BasicModel instances.
        """
        items = ["foo", "bar", "baz"]
        for item in items:
            t = ForeignKeyTarget(name=item)
            t.save()
            ForeignKeySource(name="source_" + item, target=t).save()

        self.objects = ForeignKeySource.objects
        self.data = [{"id": obj.id, "name": obj.name} for obj in self.objects.all()]
        self.view = FKInstanceView.as_view()
開發者ID:nazarewk,項目名稱:django-rest-framework,代碼行數:13,代碼來源:test_generics.py

示例4: setUp

    def setUp(self):
        """
        Create 3 BasicModel instances.
        """
        items = ['foo', 'bar', 'baz']
        for item in items:
            t = ForeignKeyTarget(name=item)
            t.save()
            ForeignKeySource(name='source_' + item, target=t).save()

        self.objects = ForeignKeySource.objects
        self.data = [
            {'id': obj.id, 'name': obj.name}
            for obj in self.objects.all()
        ]
        self.view = FKInstanceView.as_view()
開發者ID:patrickdizon,項目名稱:django-rest-framework,代碼行數:16,代碼來源:test_generics.py

示例5: setUp

 def setUp(self):
     target = ForeignKeyTarget(name="target-1")
     target.save()
     new_target = ForeignKeyTarget(name="target-2")
     new_target.save()
     for idx in range(1, 4):
         source = ForeignKeySource(name="source-%d" % idx, target=target)
         source.save()
開發者ID:Xinte,項目名稱:django-rest-framework,代碼行數:8,代碼來源:test_relations_pk.py

示例6: test_queryset_size_with_limited_choices

 def test_queryset_size_with_limited_choices(self):
     limited_target = ForeignKeyTarget(name="limited-target")
     limited_target.save()
     queryset = ForeignKeySourceWithLimitedChoicesSerializer().fields["target"].get_queryset()
     assert len(queryset) == 1
開發者ID:rsalmaso,項目名稱:django-rest-framework,代碼行數:5,代碼來源:test_relations_pk.py


注:本文中的tests.models.ForeignKeyTarget類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。