解决 AttributeError: 'ForeignKey' object has no attribute 'rel'
解决办法
# print('rel...',filter_field_obj.re.to.objects.all())
print("rel...", filter_field_obj.remote_field.model.objects.all())
步骤
forekey中存在rel,诶什么不能调用?
publish 1111111111 app01.Book.publish 2222222222 <class 'django.db.models.fields.related.ForeignKey'> rel... {'name': 'publish', 'verbose_name': 'publish', '_verbose_name': None, 'primary_key': False, 'max_length': None, '_unique': False, 'blank': False, 'null': False,
'remote_field': <ManyToOneRel: app01.book>, 'is_relation': True, 'default': <class 'django.db.models.fields.NOT_PROVIDED'>, 'editable': True,
'serialize': True, 'unique_for_date': None, 'unique_for_month': None, 'unique_for_year': None, 'choices': [], 'help_text': '', 'db_index': True,
'db_column': None, '_db_tablespace': None, 'auto_created': False, 'creation_counter': 69, '_validators': [], '_error_messages': None,
'error_messages': {'invalid_choice': 'Value %(value)r is not a valid choice.', 'null': 'This field cannot be null.', 'blank': 'This field cannot be blank.',
'unique': '%(model_name)s with this %(field_label)s already exists.', 'unique_for_date': '%(field_label)s must be unique for %(date_field_label)s %(lookup_type)s.',
'invalid': '%(model)s instance with %(field)s %(value)r does not exist.'}, 'from_fields': ['self'], 'to_fields': ['nid'], 'swappable': True, 'db_constraint': True,
'attname': 'publish_id', 'column': 'publish_id', 'concrete': True, 'model': <class 'app01.models.Book'>, 'opts': <Options for Book>, 'related_model': <class 'app01.models.Publish'>,
'validators': [], '_related_fields': [(<django.db.models.fields.related.ForeignKey: publish>, <django.db.models.fields.AutoField: nid>)]}
self.remote_field = rel
SIP协议
PAT (Basic Level) Practice 1008 数组元素循环右移问题
LeetCode-Algorithms 1. 两数之和
PAT (Basic Level) Practice 1040 有几个PAT
PAT (Basic Level) Practice 1023 组个最小数
PAT (Basic Level) Practice 1021 个位数统计
PAT (Basic Level) Practice 1007 素数对猜想
PAT (Basic Level) Practice 1006 换个格式输出整数
PAT (Basic Level) Practice 1004 成绩排名
- 最新文章
-
VMware系统运维(二十)部署虚拟化桌面Horzion View 5.2 HTML Access进行连接测试
VMware系统运维(十九)部署虚拟化桌面 Horizon View 5.2 通过手持设备进行连接测试
VMware系统运维(十八)部署虚拟化桌面 通过View Client进行连接测试
VMware系统运维(十七)部署虚拟化桌面 Horizon View Manager 5.2 配置池授权
VMware系统运维(十六)部署虚拟化桌面 Horizon View Manager 5.2 配置池
JavaScript 表格指定列,根据相同值跨行
BootStrap DataTables Spring MVC简单增删改查实例
bootstrapValidator submitHandler
EasyUI Tree_box 配合后台
[转]Oracle 删除重复数据只留一条