解决 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
final finally finalize区别?
LeetCode122-买卖股票的最佳时机2(贪心算法)
LeetCode119-杨辉三角2(题目有Bug,动态规划)
九度OJ 1051:数字阶梯求和 (大数运算)
九度OJ 1050:完数 (数字特性)
九度OJ 1049:字符串去特定字符 (基础题)
九度OJ 1048:判断三角形类型 (基础题)
九度OJ 1047:素数判定 (素数)
九度OJ 1046:求最大值 (基础题)
- 最新文章
-
Java异常学习总结一
2017-01-19
sublimeText3最新教程-自带插件汉化(sublime-text_build-3175_amd64)
PMBOK十大知识领域是什么?
一个人有成长过程
IT人士级别的划分
项目管理5大过程组,42个过程
有哪些比较好用的开源项目管理工具?
猴子管理法则
什么是蘑菇管理定律
- 热门文章
-
时间管理——华为成功之宝
解决Android Studio Conflict with dependency 'com.android.support:support-annotations'报错
说说事务的概念,在JDBC编程中处理事务的步骤。
execute,executeQuery,executeUpdate的区别是什么?
JDBC访问数据库的基本步骤是什么?
java.util.Date和java.sql.Date有什么区别?
JDBC的ResultSet是什么?
JDBC的PreparedStatement是什么?
ArrayList、LinkedList、Vector 的区别?
== 和 equals 的区别是什么?