#NEWLINE# def test_foreign_key_field( self ) : #NEWLINE# #INDENT# class ForeignTestModel ( CollectionModel ) : #NEWLINE# #INDENT# test_field = CharField ( required = True ) #NEWLINE# #UNINDENT# class TestModel ( CollectionModel ) : #NEWLINE# #INDENT# other = ForeignKeyField ( to = ForeignTestModel , required = True ) #NEWLINE# #UNINDENT# ForeignTestModel . init ( ) #NEWLINE# TestModel . init ( ) #NEWLINE# model_1 = ForeignTestModel ( ) #NEWLINE# model_1 . test_field = 'ddd' #NEWLINE# model_2 = TestModel ( ) #NEWLINE# model_2 . other = model_1 #NEWLINE# model_1 . save ( ) #NEWLINE# model_2 . save ( ) #NEWLINE# all_test_models = TestModel . objects . all ( ) #NEWLINE# self . assertEqual ( len ( all_test_models ) , 1 ) #NEWLINE# real_model = all_test_models [ 0 ] #NEWLINE# self . assertEqual ( real_model . other . test_field , model_1 . test_field ) #NEWLINE# ForeignTestModel . destroy ( ) #NEWLINE# TestModel . destroy ( )