本文整理汇总了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;未经允许,请勿转载。 |
请发表评论