[英]Django : int() argument must be a string or a number, not 'Plain'
I have rather simple problem i guess. 我想我有一个相当简单的问题。 But i cant find a solution.
但是我找不到解决方案。 It's been a while since i was writing in python/django...
自从我用python / django编写以来已经有一段时间了...
My simple problem is, when im trying to add new Plain by admin interface. 我的简单问题是,当我尝试通过管理界面添加新的Plain时。
TypeError: int() argument must be a string or a number, not 'Plain'
Site with form is rendering correctly, everything is fine till adding... 具有表单的网站可以正确呈现,添加之前一切正常。
This is code of the models: 这是模型的代码:
class Locomotion(models.Model):
transportation_firm_name = models.CharField(max_length=200)
transportation_number = models.CharField(max_length=200)
departure_date_time = models.DateTimeField()
arrival_date_time = models.DateTimeField()
class Meta:
abstract = True
def __str__(self):
return self.transportation_name
class Plain(Locomotion):
seat_number = models.CharField(max_length=200)
class_section = models.CharField(max_length=200)
def __init__(self, *args, **kwargs):
super(Locomotion, self).__init__(self, *args, **kwargs)
def __str__(self):
return "plain"
class Train(Locomotion):
seat_number = models.CharField(max_length=200)
section_numbers = models.CharField(max_length=200)
def __init__(self, *args, **kwargs):
super(Locomotion, self).__init__(self, *args, **kwargs)
And the same is happening when im trying to add Train or any other element of class extending Locomotion. 当我尝试添加Train或扩展Locomotion的任何其他类元素时,也会发生同样的情况。
When you call super
, you don't need to pass self
: 当您调用
super
,您不需要传递self
:
super(Plain, self).__init__(*args, **kwargs)
Also, note that usually, you want to call super
passing the class that you are calling it from, Plain
in this case. 另外,请注意,通常情况下,您要调用
super
传递您从其调用的类,在这种情况下为Plain
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.