簡體   English   中英

django資源獲取所有字段(manytomany,外鍵等)

[英]django resource get all fields ( manytomany,foreign key etc.)

從我的問題中可以看出,我想從 users 表中下載所有其他相關表中的數據。

class UserResource(resources.ModelResource):
    class Meta:
        model = User
        fields = ['__all__'] # But I want ALL FIELDS ( foreign key fields etc.)

我認為fields = '__all__' ,而不是fields = ['__all__'] 而當你想添加額外的字段時,你可以設置extra_fields屬性。

...
fields = '__all__'
extra_fields = ['extra']

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM