简体   繁体   中英

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

As you can see from my question, I want to download data from all other relevant tables from the users table.

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

I think fields = '__all__' , not fields = ['__all__'] . And when you want to add the extra field, you can set the extra_fields attribute.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM