解决办法

# 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

如何取出对应的数据

大功告成

            # print('rel...',filter_field_obj.re.to.objects.all())
print('rel...',filter_field_obj.__dict__)
print('rel...',filter_field_obj.remote_field)
print('rel...',filter_field_obj.remote_field.__dict__)
print("rel...", filter_field_obj.remote_field.model.objects.all())

4

3

解决 AttributeError: 'ForeignKey' object has no attribute 're'的更多相关文章

  1. 解决AttributeError: 'Ui_MainWindow' object has no attribute 'show'报错

    1.首先使用pyqt designer来设计ui界面,将其保存为"***.ui"文件, 然后进入到pyqt所在的文件目录中,执行cmd中命令,即在当前目录中可以生成相应的**.py ...

  2. AttributeError: 'ForeignKey' object has no attribute 're' 解决办法

    使用 field_object.rel.model.objects.filter(**db_condition) 报错 forekey中存在rel,为什么不能调用? 通过以下语句观察 print(fi ...

  3. 解决AttributeError: 'module' object has no attribute 'main' 安装第三方包报错

    1.找到pycharm 目录下的 \helper\packaging_tool.py 文件 2.用新版pycharm 的packaging_tool.py 替换 旧版 同名文件 文件代码如下: imp ...

  4. AttributeError: 'SQLAlchemy' object has no attribute 'Foreignkey'

    在学习<Flask Web开发----基于Python的Web应用开发实战>的过程中,调试程序,如下图,运行报错: AttributeError: 'SQLAlchemy' object ...

  5. attributeError:'module' object has no attribute ** 解决办法

    写了一个小脚本,执行的时候报错: Traceback (most recent call last): File "F:/test/qrcode.py", line 109, in ...

  6. 对于AttributeError: 'Flask' object has no attribute 'cli'的解决办法

    版权声明:本文为博主原创文章,未经博主允许不得转载. 环境flask-script2.0.5.flask0.10.1 运行官方文档sample 出现问题 c:\kk\flask\examples\fl ...

  7. 解决window7 x64位Anaconda启动报错:AttributeError: '_NamespacePath' object has no attribute 'sort'

    最近论文需要用到python做数据分析,python语法简单,但是Windows下安装第三方包恶心的要命,statsmodels用pip死活安装不上,网上查了说包相互依赖windows下的pip不能下 ...

  8. Python使用suds调用webservice报错解决方法:AttributeError: 'Document' object has no attribute 'set'

    使用python的suds包调用webservice服务接口,报错:AttributeError: 'Document' object has no attribute 'set' 调用服务接口代码: ...

  9. 解决Win7(x64)Anaconda3报错:AttributeError: '_NamespacePath' object has no attribute 'sort'

    最近论文需要用到python做数据分析,python语法简单,但是Windows下安装第三方包恶心的要命,statsmodels用pip死活安装不上,网上查了说包相互依赖windows下的pip不能下 ...

随机推荐

  1. tcp没用吗?为什么MOBA、“吃鸡”游戏不推荐用tcp协议

    本文由云+社区发表 作者:腾讯云游戏行业资深架构师 余国良 MOBA类和"吃鸡"游戏为什么对网络延迟要求高? 我们知道,不同类型的游戏因为玩法.竞技程度不一样,采用的同步算法不一样 ...

  2. [四] JavaIO之类层次体系结构横向比对

      IO家族类层次体系结构横向匹配   上一篇文章中主要介绍了JavaIO流家族的整体设计思路,简单回顾下 基本逻辑涉及数据源 流的方向,以及流的数据形式这三个部分的组合 按照流的数据形式和流的方向, ...

  3. 第31章 日志 - Identity Server 4 中文文档(v1.0.0)

    IdentityServer使用ASP.NET Core提供的标准日志记录工具.Microsoft文档有一个很好的介绍和内置日志记录提供程序的描述. 我们大致遵循Microsoft使用日志级别的指导原 ...

  4. mysql报错:java.sql.SQLException: Incorrect string value: '\xE4\xB8\x80\xE6\xAC\xA1...' for column 'excelName' at row 1

    一.问题 用Eclipse做项目时候报错 java.sql.SQLException: Incorrect string value: '\xE4\xB8\x80\xE6\xAC\xA1...' fo ...

  5. 编译内核时出现drivers/mfd/mxc-hdmi-core.c:36:24: fatal error: mach/clock.h: No such file or directory

    在学习恩智浦IMX6D开发板时,编译内核出现 drivers/mfd/mxc-hdmi-core.c::: fatal error: mach/clock.h: No such file or dir ...

  6. 2018年终总结之AI领域开源框架汇总

    2018年终总结之AI领域开源框架汇总 [稍显活跃的第一季度] 2018.3.04——OpenAI公布 “后见之明经验复现(Hindsight Experience Reply, HER)”的开源算法 ...

  7. Android 通过反射获取DatePicker 中的控件,并改变其颜色

    到最后也只是成功改变了中间部分的颜色. private void setDatePickerDividerColor(DatePicker datePicker) { // Divider chang ...

  8. 加载loading对话框的功能(不退出沉浸式效果)

    上一篇基于修改系统源码的前提下,实现了完全的沉浸式体验效果.可参考这篇 戳这 一.自定义Dialog 在沉浸式效果下,当界面弹出对话框时,对话框将获取到焦点,这将导致界面退出沉浸式效果,那么是不是能通 ...

  9. Android Camera2 预览功能实现

    1. 概述 最近在做一些关于人脸识别的项目,需要用到 Android 相机的预览功能.网上查阅相关资料后,发现 Android 5.0 及以后的版本中,原有的 Camera API 已经被 Camer ...

  10. Redis进阶学习笔记

    Redis是什么这里不用再说了吧?下面是官方的解释 Redis is an open source (BSD licensed), in-memory data structure store, us ...