本文整理匯總了Python中rest_framework.tests.models.ForeignKeyTarget類的典型用法代碼示例。如果您正苦於以下問題:Python ForeignKeyTarget類的具體用法?Python ForeignKeyTarget怎麽用?Python ForeignKeyTarget使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ForeignKeyTarget類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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()
示例2: 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()
示例3: 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()