python如何声明变量_python-如何在类中定义带有值的变量以及如何在其他类中使用...

我课外有变数.需要变量才能正常使用类.如何在课堂上移动它并在其他课堂上使用它?

这很好用,但是我需要在UserDevice类中移动STATUS_CHOICES并在UserDeviceAdmin中使用STATUS_CHOICES.

STATUS_CHOICES = ((0,gettext("disabled")),(1,gettext("allowed")))

class UserDevice(BaseModel):

"""Table with all devices added and owned by users."""

device_uniqueid = CharField(primary_key=True)

device_user = ForeignKeyField(User,null=True,backref='userdevices')

device_name = CharField()

model = CharField()

phone = CharField()

status = IntegerField(choices=STATUS_CHOICES,default=1)

inserted_at = DateTimeField(null=True)

def myfunc(self):

return self.a

class UserDeviceAdmin(ModelView):

can_create = False

edit_modal = True

column_choices = {'status': STATUS_CHOICES}

column_list = [

'device_uniqueid','device_user.email','device_name','model','phone','status','inserted_at',]

column_sortable_list = ('device_uniqueid','device_user.email')

form_ajax_refs = {'device_user': {'fields': ['email']}}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值