このガイドに従って、独自のカスタム モデル フィールドを作成しようとしています https://docs.djangoproject.com/en/2.1/howto/custom-model-fields/
class Hand:
"""A hand of cards (bridge style)"""
def __init__(self, north, east, south, west):
# Input parameters are lists of cards ('Ah', '9s', etc.)
self.north = north
self.east = east
self.south = south
self.west = west
# ... (other possibly useful methods omitted) ...
次のステップは (モデルの手属性が Hand のインスタンスであると仮定します)
example = MyModel.objects.get(pk=1)
print(example.hand.north)
new_hand = Hand(north, east, south, west)
example.hand = new_hand
example.save()
「モデルの手属性は手のインスタンスであると想定しています」
誰かが例を提供できますか?