django-import-export

Django import export Line number: 1 - u\"Column 'id' not found

我与影子孤独终老i 提交于 2019-12-04 07:26:15
I am trying to import excel documents into a Django DB. I have added the following code to admin.py and model.py . There seems to be an error in the development of Django. I have read through several different documentations about how to fix this error. But I am still a little lost on how to implement it exactly. In the Trace it keeps saying that my excel document needs an id field. There is no id field in my excel docs nor did I tell my model to look for an id field. The documentation that I have found states that I should use get_or_init_instance here: https://django-import-export

Extending the admin import form for django import_export

社会主义新天地 提交于 2019-12-01 20:55:56
问题 I'm using Django import_export to implement CSV upload in my admin pages. Now I have one model, that contains a foreign key column, but the foreign key column will have only one value for each import. Therefore I would like to allow the user to choose the related model instance from a drop-down instead of forcing the user to append the columns themselves. In order to do this I need to customize the import form, which requires overriding the default methods import_action and process_import ,

Extending the admin import form for django import_export

二次信任 提交于 2019-12-01 18:58:24
I'm using Django import_export to implement CSV upload in my admin pages. Now I have one model, that contains a foreign key column, but the foreign key column will have only one value for each import. Therefore I would like to allow the user to choose the related model instance from a drop-down instead of forcing the user to append the columns themselves. In order to do this I need to customize the import form, which requires overriding the default methods import_action and process_import , but my efforts so far have shown no effect. Here is what I have so far: from django import forms from

How to have only CSV, XLS, XLSX options in django-import-export?

…衆ロ難τιáo~ 提交于 2019-12-01 18:37:34
I have implemented django-import-export for my project. It provides me many file format options by default fro both import and export. How to restrict the file formats to only CSV, XLS and XLSX ? Burhan Khalid You can override the get_export_formats() method of the ExportMixin : from import_export.formats import base_formats class MyAdmin(ExportMixin): # your normal stuff def get_export_formats(self): """ Returns available export formats. """ formats = ( base_formats.CSV, base_formats.XLS, base_formats.XLSX, base_formats.TSV, base_formats.ODS, base_formats.JSON, base_formats.YAML, base_formats

Dealing with import of foreignKeys in django-import-export

 ̄綄美尐妖づ 提交于 2019-11-29 05:20:24
I don't understand how django-import-export module deals with ForeignKeys. Here is a simple exemple : models.py class TFamilies(models.Model): id_fam = models.AutoField(primary_key=True, unique=True) name_fam = models.CharField(max_length=1024, blank=True,verbose_name='Famille') class TGenus(models.Model): id_genus = models.AutoField(primary_key=True, unique=True) name_genus = models.CharField(max_length=1024,verbose_name='nom de genre') id_fam = models.ForeignKey(TFamilies, null=True, db_column='id_fam', blank=True, verbose_name='Famille') I would like to allow people adding genus with family

django-import-export: cannot exclude id field during import : KeyError: u'id'

怎甘沉沦 提交于 2019-11-28 02:20:14
问题 On Django-1.9.6, django-import-export-0.5 When I try to upload CSV without "id" field throws this error. Line number: 1 - u'id' 13173474, Harry McDade, 10.harry.asas@asasasas.com Traceback (most recent call last): File "/Users/isanka/dev/venv/edxubase/lib/python2.7/site-packages/import_export/resources.py", line 434, in import_row instance, new = self.get_or_init_instance(instance_loader, row) File "/Users/isanka/dev/venv/edxubase/lib/python2.7/site-packages/import_export/resources.py", line

Dealing with import of foreignKeys in django-import-export

半城伤御伤魂 提交于 2019-11-27 22:45:24
问题 I don't understand how django-import-export module deals with ForeignKeys. Here is a simple exemple : models.py class TFamilies(models.Model): id_fam = models.AutoField(primary_key=True, unique=True) name_fam = models.CharField(max_length=1024, blank=True,verbose_name='Famille') class TGenus(models.Model): id_genus = models.AutoField(primary_key=True, unique=True) name_genus = models.CharField(max_length=1024,verbose_name='nom de genre') id_fam = models.ForeignKey(TFamilies, null=True, db

Adding foreignKey widget to django-import-export

回眸只為那壹抹淺笑 提交于 2019-11-27 18:26:30
问题 I'm trying to import data to one of my models, but it's failing because I'm trying to upload the foreignKey Id, not the iterated number that import-export creates. models.py from django.db import models from import_export import resources class School(models.Model): name = models.CharField(max_length=100) slug = models.CharField(max_length=100) school_id = models.IntegerField(unique=True) class Sol(models.Model): school_id = models.ForeignKey(School, to_field='school_id') name = models