-1

I am using django import/export in my project.In my admin model i have two fields "choose file" for choosing files and "select format" for selecting formats csv, xls and json. how can i do java-script validation to make sure that user chooses only one of the 3 file types? how to validate the chosen file extension and selected format are same?

4

1 回答 1

1

它不需要javascript来做。只需attributes使用ImportMixin.

class BookResource(resources.ModelResource):
    formats = (<class 'import_export.formats.base_formats.CSV'>, 
               <class 'import_export.formats.base_formats.XLS'>, 
               <class 'import_export.formats.base_formats.JSON'>)
    class Meta:
        model = Boo

链接:formats

于 2015-03-02T11:59:25.423 回答