class Category(models.Model):
categoryid = models.AutoField(db_column='CategoryID', primary_key=True)
categoryname = models.CharField('Name', db_column='CategoryName', unique=True, max_length=25)
categorycode = models.CharField('Code', db_column='CategoryCode', unique=True, max_length=1)
def __str__(self):
return self.categoryname
class Meta:
managed = False
db_table = 'category'
class Subcategory(models.Model):
subcategoryid = models.AutoField(db_column='SubCategoryID', primary_key=True) # Field name made lowercase.
subcategoryname = models.CharField(db_column='SubCategoryName', unique=True, max_length=25) # Field name made lowercase.
subcategorycode = models.CharField(db_column='SubCategoryCode', unique=True, max_length=1) # Field name made lowercase.
categoryid = models.ForeignKey(Category, models.DO_NOTHING, db_column='CategoryID') # Field name made lowercase.
def __str__(self):
return self.subcategoryname
class Meta:
managed = False
db_table = 'subcategory'
class Product(models.Model):
productid = models.IntegerField(db_column='ProductID', primary_key=True) # Field name made lowercase.
productname = models.CharField('Name', db_column='ProductName', max_length=30) # Field name made lowercase.
reference = models.CharField('Reference', db_column='Reference', unique=True, max_length=5) # Field name made lowercase.
subcategoryid = models.ForeignKey('Subcategory', models.DO_NOTHING, db_column='SubCategoryID') # Field name made lowercase.
providers = models.ManyToManyField(Provider, through='ProviderProduct')
def __str__(self):
return self.productname
class Meta:
managed = False
db_table = 'product'
以下是我的示例代码
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'
*** First throw call stack:
(
0 CoreFoundation 0x0000000110849c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001104e2bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000110849b9d +[NSException raise:format:] + 205
3 UIKit 0x0000000110d8713c -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 487
4 UIKit 0x00000001112ffa6b -[_UIFullscreenPresentationController _adjustOrientationIfNecessaryInWindow:forViewController:preservingViewController:] + 330
5 UIKit 0x0000000110d4ed37 -[UIPresentationController _presentWithAnimationController:interactionController:target:didEndSelector:] + 707
6 UIKit 0x0000000110d7e576 -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 756
7 UIKit 0x0000000110d7f76e -[UIViewController _presentViewController:withAnimationController:completion:] + 3079
8 UIKit 0x0000000110d816c1 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 132
9 UIKit 0x0000000110d815e5 -[UIViewController presentViewController:animated:completion:] + 229
10 redminete 0x000000010ff92a11 -[LoginViewController btnsingin:] + 1537
11 UIKit 0x0000000110c43d62 -[UIApplication sendAction:to:from:forEvent:] + 75
12 UIKit 0x0000000110d5550a -[UIControl _sendActionsForEvents:withEvent:] + 467
13 UIKit 0x0000000110d548d9 -[UIControl touchesEnded:withEvent:] + 522
14 UIKit 0x0000000110c90958 -[UIWindow _sendTouchesForEvent:] + 735
15 UIKit 0x0000000110c91282 -[UIWindow sendEvent:] + 682
16 UIKit 0x0000000110c57541 -[UIApplication sendEvent:] + 246
17 UIKit 0x0000000110c64cdc _UIApplicationHandleEventFromQueueEvent + 18265
18 UIKit 0x0000000110c3f59c _UIApplicationHandleEventQueue + 2066
19 CoreFoundation 0x000000011077d431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
20 CoreFoundation 0x00000001107732fd __CFRunLoopDoSources0 + 269
21 CoreFoundation 0x0000000110772934 __CFRunLoopRun + 868
22 CoreFoundation 0x0000000110772366 CFRunLoopRunSpecific + 470
23 GraphicsServices 0x0000000113d6fa3e GSEventRunModal + 161
24 UIKit 0x0000000110c428c0 UIApplicationMain + 1282
25 redminete 0x000000010ff9bd93 main + 99
26 libdyld.dylib 0x0000000112ded145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
如何解决这个问题。