腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
1
回答
read_only_fields
的
默认值
django
、
django-rest-framework
有一个扩展serializers.ModelSerializer
的
FooSerializer model = Foo
read_only_fields
= [] 是否每次都必须将
read_only_fields
设置为空列表,
浏览 1
提问于2017-07-31
得票数 1
回答已采纳
1
回答
DRF ModelSerializer使所有字段只读取,而不明确地指定它们。
python-3.x
、
serialization
、
django-models
、
django-rest-framework
每次修改Foo时,不更新我
的
序列化程序会容易得多。serializers.ModelSerializer): model = Foo
read_only_fields
= fieldsException Type: TypeError at /api/foo/ ExceptionValue
浏览 3
提问于2019-08-13
得票数 4
回答已采纳
2
回答
Python列表/元组pop返回自己?
python
这可能是初步
的
,但经过一些搜索,我找不到一个方法,但pop(),del,remove()。= ('id','user','created_at','voters','is_public','updated_at','pagevote','pageidenticals') 注意fields和
read_only_fields
上
的
冗余。两者
的
唯一区别是title'
浏览 10
提问于2022-09-02
得票数 1
回答已采纳
1
回答
在Swagger中显示Django Rest框架
的
最大值、最小值和
默认值
python
、
django
、
django-rest-framework
、
swagger
、
swagger-ui
我正在为我
的
API开发一个v2,我想正确地记录它。由于我使用Django Rest Framework (3.1.1),并且在他们
的
文档中建议使用Swagger,所以我使用它。在文档中,我看到它
的
一个特性是显示“字段
默认值
、最小、最大、只读和必需
的
属性”。但是,在我
的
示例中,我只看到"Description“、"Parameter”和"Data“,如图像中所示:我希望看到更多列,如最小列、最大值列和
默认值
列,其中
的</e
浏览 2
提问于2016-01-04
得票数 1
回答已采纳
1
回答
Django模型默认字段被seriliazer覆盖
python
、
django
、
django-rest-framework
在模型中,我将publish
的
默认值
设置为True,但是在EntrySerializer中创建新条目后,它将保存为False。我可以通过在序列化程序中重写create()方法来手动纠正这一点,但我想知道还有一种更优雅
的
方法。serializers.ModelSerializer): model = Entry
read_only_fields
= ['author',
浏览 3
提问于2022-02-22
得票数 0
1
回答
Django序列化程序在创建时返回空字典。
django
、
django-rest-framework
我有一个基本连接两个不同用户
的
模型: id = models.UUIDField( related_name="user2" return str(self.id) user.save() part
浏览 2
提问于2022-11-23
得票数 0
1
回答
动态创建DRF序列化程序类
django
、
django-rest-framework
我有几个相同型号
的
DRF序列化器类。我希望将类创建代码移到函数中,以避免代码重复。 class CourseSerializer(serializers.ModelSerializerTrue) class Meta: fields = field
浏览 0
提问于2020-12-31
得票数 0
回答已采纳
1
回答
为什么在使用序列化程序时忽略queryset.only()?
python
、
django
、
django-rest-framework
、
django-queryset
、
django-serializer
我
的
应用程序使用Django和REST框架。指定查询集:queryset = queryset.only('branch').distinct
浏览 2
提问于2022-01-27
得票数 0
1
回答
在Django序列化程序中,如何根据视图参数设置外键字段?
python
、
django
、
serialization
、
django-rest-framework
其中一个字段(名为domain
的
外键字段)将根据urls.py中定义
的
视图参数确定。虽然我已经准备好了模型和视图/序列化器结构
的
代码,但我不知道如何告诉序列化程序根据视图参数确定domain字段
的
值。Meta: fields = ('created', 'updated', 'domain', 'name', 'type',)
re
浏览 2
提问于2017-05-08
得票数 4
回答已采纳
1
回答
django-rest框架ManyToManyField创建和更新
python
、
django
、
django-models
、
django-rest-framework
、
manytomanyfield
我是Django
的
新手,所以我有一些问题。我在使用django-rest框架。我想要一个产品序列化程序和一个视图集,允许创建一个产品
的
大小。class Meta: fields = ('id', 'name', 'price', 'sizes')上面所写
的
序列化程序允许获得带有其大小
的
浏览 0
提问于2015-03-22
得票数 4
回答已采纳
2
回答
无法序列化只读字段
python
、
django
、
django-rest-framework
我想序列化只读字段(执行get请求并查看所有对象) GET fields = ('id', 'building', 'name', 'url', 'zone_id_x', 'zone_id_y')
浏览 2
提问于2021-06-14
得票数 0
回答已采纳
1
回答
没有rest
的
更新字段
django
、
django-rest-framework
我有model.py ...我想用代码制作awaiting_confirmation = True。但禁止awaiting_confirmation通过RestAPI调用进行更新。class UserPaymentInformationUpdateAPIView(generics.UpdateAPIView): permission_classe
浏览 3
提问于2021-02-23
得票数 0
2
回答
提供给EmbeddedDocumentField
的
无效嵌入式文档实例
django
、
django-rest-framework
、
mongoengine
、
restframeworkmongoengine
ReferenceField(Food) complementory = BooleanField(default = False) class Meta: fields = 'all'
浏览 5
提问于2018-02-27
得票数 3
回答已采纳
1
回答
Django Rest框架SerializerMethodField仅针对GET请求
django
、
django-rest-framework
我
的
DRF后端在这里遇到了一点小麻烦。我对一种型号有外键要求。当我创建模型时,我想将它保存在外来id下。当我请求模型时,我希望模型具有任何选择字段映射到
的
内容。 model = apps.get_model('backend
浏览 1
提问于2018-07-30
得票数 2
回答已采纳
1
回答
如何编写生成具有不同元类
的
类
的
类工厂
python
、
django
、
django-rest-framework
、
metaclass
我想创建一个类工厂,它生成具有不同Meta类
的
序列化器类。fields = ( 'maths', ) 'maths',我想根据传递给工厂
的
参数更改只读字段和字段元组。请给我指出正确
的
方向
浏览 3
提问于2015-06-30
得票数 1
回答已采纳
3
回答
如何使用django rest框架获取模板中
的
模型选择字段名而不是id
python
、
django
、
django-rest-framework
我在template.But中获取选择字段
的
id,我想要显示选择字段
的
名称。请查阅以下文件,并让我知道如何获得名称。这是我
的
models.pyclass Posted(models.Modelfields = ('id','author','title','tags','posted','content&
浏览 0
提问于2016-08-28
得票数 2
回答已采纳
3
回答
如何在django rest框架中保存时间戳字段
django
、
django-rest-framework
det_id','latitude','longitude','start_or_end','user_id','username','type','timestamp') 在上面,时间戳字段是由数据库自动设置
的
,获取此插入记录
的
id并将其添加到另一个日志表
的
正确方法是什么?
浏览 190
提问于2018-06-20
得票数 1
回答已采纳
1
回答
在django restframework视图中显示外键选项
python
、
django
、
serialization
、
django-rest-framework
我收到一个错误,上面写着我正在寻找
的
主要功能是发布一份职位列表,以便在申请该职位时可供选择。, 'city', 'state', 'salary', 'position', 'employer', 'created_date', 'is_active', 'applicants')
read_only_fi
浏览 2
提问于2021-01-26
得票数 0
回答已采纳
2
回答
错误:(admin.E035) 'readonly_fields[0]‘
的
值不是可调用
的
python-3.x
、
django
但是写这个错误:(我立即在搜索中插入问题,但没有找到决定。我读了
的
问题,但还没有写完 admin.pyfrom .models import
浏览 16
提问于2022-05-01
得票数 0
回答已采纳
1
回答
django rest框架工作列'product_id‘不能为空
python
、
django
、
django-rest-framework
我有这样
的
观点,我想在用post方法接收产品id时,在DB中保存一条记录。(1048, "Column 'product_id' cannot be null")# product peyment 'created_date', ]
浏览 0
提问于2018-03-06
得票数 0
回答已采纳
点击加载更多
相关
资讯
python参数默认值
Jmeter元件HTTP请求默认值
Kotlin基础十一函数默认值
Python 小技巧-字典默认值
15-Not NULL约束与默认值
热门
标签
更多标签
云服务器
ICP备案
对象存储
云点播
即时通信 IM
活动推荐
运营活动
广告
关闭
领券