Questions tagged [django-import-export]

1

votes
1

answer
256

Views

Django-import-export get file name

I've been scouring the docs and internet for a couple days now trying to figure out how I can capture the imported filename from Django import export admin panel's import feature. Basically, I want to save this filename to ensure that future file uploads are not the same. the process being: Some...
bfen3774
1

votes
1

answer
240

Views

django-import-export form <input> not rendering in custom admin template w/ grappelli

after implementing django-import-export on a project using django-grappelli for admin UI, I've discovered there are some CSS incompatibilities between the two libs: https://github.com/sehmaschine/django-grappelli/issues/435 to address this, I created custom admin template overwrites so import-export...
Chris B.
1

votes
1

answer
520

Views

Django-import-export before_import_row to automatically create object if it does not exist

I'm facing the current issue when using Django-import-export: inside my admin.py : class QuestionResource(resources.ModelResource): category = fields.Field( column_name='category', attribute='category', widget=ForeignKeyWidget(Category, 'category') ) class Meta: model = Question fields = ['id', 'que...
Tony Kyriakidis
1

votes
1

answer
231

Views

django-import-export export is slow when there is foreign key

when there is foreign key in model, exporting is very slow, when I exclude the foreign there is no problem, it starts to download quickly. What might be the issue here? Thanks! My code is like, resources.py class InvoiceResource(resources.ModelResource): class Meta: model = Invoices views.py def exp...
1

votes
1

answer
101

Views

download zip file with data from multiple models in csv format

I'm using Django 2.0 I have to download data from multiple models in csv format zipped in a zip file. I'm using django-import-export plugin to generate csv file for the model data What I'm doing is def download_all_data(request): # user data user_resource = UserResource() queryset = User.objects.fil...
Anuj TBE
1

votes
1

answer
66

Views

django-import-export keyerror, when using OneToOneField

My models.py file is from django.db import models class companyDetail(models.Model): short_code = models.CharField(primary_key=True, max_length=50) title = models.CharField(max_length=50) page_title = models.CharField(max_length=50) class Meta: verbose_name = 'companyDetail' verbose_name_plural = 'c...
Abhimanyu Singh
1

votes
0

answer
25

Views

How to install a modified python package

I have modified the django-import-export package, now I need to upload my application to Heroku and use the modifications that I have made. I have created a github repository and uploaded the files of the folder import_export. Now How can I use this modificated package into my project?
Matheus Sant'ana
1

votes
0

answer
36

Views

How to import excel files in django that has a foreign key?

I am trying to import excel file through django admin(Import-export). I have two tables. Brand master and Item master. I am using Brand Master as a foreign key in Item master. When I upload brand master file, it is uploading. But when I try to import Item master there is a problem Below is the model...
1

votes
2

answer
2.3k

Views

Import VARBINARY(MAX) column data from remote SQL Server (other domain) to local SQL Server

I have to import the table data in VARBINARY(MAX) format from one SQL Server (located on remote machine on other domain where i can connect through RDP connection) to my local box. i did try the method to export the data from source to txt file by casing column to VARCHAR(MAX) but after import the...
Atul Bansal
1

votes
1

answer
204

Views

Dont save in DB repeated rows with Django import-export

Im importing an xls file with django import-export and all working fine, now i need delete the rows that has the same strings, i mean id - name 1 - Jhon 2 - Jhon 3 - Peter Only insert in DB when importing the rows 2 and 3 Until now, i have this: class ProyectosResource(resources.ModelResource):...
dfrojas
0

votes
0

answer
5

Views

django-import-export how to handle GenericRelations?

I'm using django-import-export module to export the record. However, I couldn't export the generic relations. I just want to get all the details of GenericRelation. Found the snippet below in Github but it doesn't work. class DudeResource(resources.ModelResource): address = fields.Field( column_na...
Wreeecks
1

votes
1

answer
1k

Views

django-import-export: How to import data with foreign keys that doesn't have the keys, but the names?

I am trying to set up django-import-export to handle my data which is stored in spreadsheets. The spreadsheets don't contain foreign keys as IDs, but rather they contain the (also unique) names of the correlating object. Within my database I will have foreign key relationships of Teachers who work a...
D. Joe
1

votes
1

answer
206

Views

import m2m with Django-import-export failing

Data import using django-import-export is failing for m2m relationships. The transaction doesn't generate any errors, however when trying to update an object's m2m relationship none of the updated values for m2m are being updated. models.py class Category(MPTTModel): name = models.CharField(max_len...
javiercf
1

votes
1

answer
511

Views

Export button is not visible with django-import-export package

I am trying to use django-import-export module in my admin and here are my settings admin.py from import_export.admin import ImportExportMixin, ImportMixin, ExportActionModelAdmin, ImportExportActionModelAdmin class RegistrationAdmin(ImportExportActionModelAdmin): list_display = ('user', 'activation...
1

votes
2

answer
1k

Views

Django import export: update without add

I'm using 'django import export' (DIE) for importing and updating some data. Import process starts from checking exists objects in DB, searching by values in ID-field, and if row with ID from import file not found - new entre will be created. How can i made 'update only' scenario, where if 'id key...
Nikita Bel
1

votes
1

answer
639

Views

How to access row data in before_save_instance for Django Import Export

I'm trying to use django-import-export to load data into my Django site admin interface. During the input I want to do some complicated data validation which involves creating and/or modifying other models related to the one being uploaded into with django-import-export. It seems like the before_sav...
deadcode
1

votes
2

answer
870

Views

How to do field validation in django-import-export

Following is my model: class Product(models.Model): product_title = models.CharField(max_length=100, null=False, verbose_name='Product title') product_description = models.TextField(max_length=250, verbose_name='Product description') product_qty = models.IntegerField(verbose_name='Quantity') produ...
Gautam Mandewalker
1

votes
2

answer
409

Views

Can not import without id

Software: Python3.6.2 Django1.11 django-import-export==0.5.1 OSX10.12.6 INSTALLED_APPS: THIRD_PARTY_APPS = [ ..., 'reversion', # django-reversion 'import_export', # django-import-export ] Requirements: 1. Model has reversion 2. Model can be able to do import 3. Each imported role has uploade...
Sarit
1

votes
1

answer
334

Views

Extend django-import-export's import form to specify fixed value for each imported row

I am using django-import-export 1.0.1 with admin integration in Django 2.1.1. I have two models from django.db import models class Sector(models.Model): code = models.CharField(max_length=30, primary_key=True) class Location(models.Model): code = models.CharField(max_length=30, primary_key=True) sec...
Ricardo Buring
1

votes
1

answer
0

Views

Django-Import-Export to import CSV, how to work with u'\\ufeff, UTF-8 BOM issue?

When I'm trying to import CSV file using django-import-export modules gives this error, KeyError: u'Column 'id' not found in dataset. Available columns are: [u'\ufeffid', u'username', u'name', u'email']'
Isanka Wijerathne
1

votes
3

answer
0

Views

Django-import-export customization with related fields

I need to update my table every time a new value of 'sku' is entered (not to create a new entry), but it does have to happen only if the 'client' selected is the same. If the 'client' is different, then the model should add a new object with the same 'sku', but with different 'clients'. One StackOve...
Matheus Sant'ana
1

votes
1

answer
0

Views

Foreign key widget finds more than 1 value, how should i approach this

I am using django-import-export library and I am trying to implement ForeignKey widget which is available to lookup related objects using Author.name instead of Author.pk. Now, the here is the tricky part for the given calendar year I only have one author with the same name, however, next year the a...
bisamov
1

votes
1

answer
611

Views

How to combine two or more ModelAdmins in django admin

There are two custom ModelAdmins provided by contrib projects which I'd like to combine on a single model's administrative interface. How do I combine two or more ModelAdmins on a single model such that they both apply to the same administrative interface? My particular scenario: I'm building a gis...
Tristan
1

votes
1

answer
518

Views

Django import-export exclude not working

I've been working with Django import-export so that I can get csv files from my database. These csv files have some fields that aren't relevant since they are changed when items are put into the database and thus I dont want them in the table. I have followed the docs for import-export but can't se...
Gary
1

votes
1

answer
106

Views

Django using more than 1 package for admin site

I am using 2 django packages: Admin sortable (For changing the order of models) and Django import export (For importing csv directly into my models). The problem is that if I add the 2 packages into my model admin e.g. class CategoryAdmin(SortableAdmin, ImportExportModelAdmin): they override each ot...
Rgfvfk Iff
1

votes
1

answer
693

Views

How to export property values with django-import-export

My model: class TreeNode(MPTTModel): ... @property def pay_progress(self): return '{}/{}'.format(self.annuities.exclude(fact_date=None).aggregate(Sum('total'))['total__sum'] or 0, self.annuities.aggregate(Sum('total'))['total__sum']) Resources: from import_export import resources from models import...
tonyjasta
0

votes
0

answer
3

Views

InvalidDimensions Error. How can I gain access to the Dataset to format it before the tablib error through django-import-export

I'm using django-import-exportand receiving the following error when trying to upload a csv file: InvalidDimensions encountered while trying to read file I know that this is a tablib error, and due to the fact that I have an empty line between each row in my csv, as well as blank lines at the end of...
juju
1

votes
1

answer
35

Views

Is there a generic way to implement column names?

I'm trying to implement the django-import-export library in a generic way. When setting the fields property in the Meta class there isn't a way to set the column names. When setting a Field() on the ModelResource directly it is possible. But as far as I know, you can't create those in a generic way....
user3488657
0

votes
0

answer
4

Views

fix error KeyError: 'id' in import_export django package while importing excel file

i am trying to import excel file into sqlite 3 database using import_export package in django. excel file consiste of 2 columns : id:(empty values) name:(contains values) its not working and display the below error: Errors Line number: 1 - 'id' None, smugling Traceback (most recent call last): File...
Django Dg
1

votes
2

answer
448

Views

How to get request in ModelResource django-import-export

How to get request.user from method queryset of ModelResource in django-import-export? class PeopleResource(ModelResource): class Meta: model = People exclude = ('id','agent', 'public_id', 'active') def dehydrate_placeA(self, people): ... ... def get_queryset(self): query = People.objects.filter( .....
aldyahsn
1

votes
4

answer
1.1k

Views

Django import-export fields

I have a short question about django-import-export. In my model I have choice list: STATE_CHOICES = ((NEW_STATE, u'New'), (DELIVERED_STATE, u'Delivered'), (LOST_STATE, u'Lost'), And method that handles mapping choices for names @staticmethod def get_status_name_by_status(status): return ne...
hebius
2

votes
2

answer
4.7k

Views

Django Import/Export to multiple Models (foreignkey)

This has been asked several times- but none of the solutions worked for me. The code below works (in that there are no errors) but it does not see anything to import new data to the foreign key class. It will only import data if it already exists in the foreign key. Does that make sense? Models.py (...
Ycon
2

votes
1

answer
1.8k

Views

Dealing with import of foreignKeys in django-import-export

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...
HydrUra
2

votes
2

answer
3.2k

Views

How do I import data using Django-Import-Export?

The documentation for django-import-export is a bit weak on how to configure the admin to import from a spreadsheet. Does anyone have a full example?
seddonym
2

votes
1

answer
1.7k

Views

Django Admin import_export module used for custom IMPORT

I was trying to follow official doc of import-export: https://django-import-export.readthedocs.org/en/latest/import_workflow.html#import-data-method-workflow But I still do not know how to glue it to my admin assuming that: I want only subset of fields (I created Resource model with listed fields, b...
andilabs
3

votes
2

answer
1.4k

Views

Django-import-export - export from model's functions?

For a Django model I'm using django-import-export package. The manual says I can export fields that are not existing in the target model like so: from import_export import fields class BookResource(resources.ModelResource): myfield = fields.Field(column_name='myfield') class Meta: model = Book http:...
Alveoli
4

votes
1

answer
1.3k

Views

Django import-export importing data with object relationships

I've been playing with django import-export because it seems to be the obvious choice for anything import/export related in django and it's fantastic. Trouble is I can't find much in the way of docs on the import side of things and I'd like to be able to use it to import data through and cope with t...
markwalker_
4

votes
3

answer
359

Views

Extending the admin import form for django import_export

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 inst...
Jarno
1

votes
1

answer
573

Views

Django import-export generate username before user csv upload

I need to bulk generate users for my app from a csv file. The csv I have contains the following fields: last_name, first_name, email To generate the username I have a function which I was hoping to use in a 'dehydrate' method. The dehydrate method works only with exports, not imports. [edit] After...
jcuot
1

votes
1

answer
462

Views

oscarcommerce catalogue import

I have a magento2 project. I want to import product catalog in magento 2 into django oscarcommerce. The official documentaion explains an importer (http://django-oscar.readthedocs.io/en/releases-1.1/howto/importing_a_catalogue.html). But that they are not supporting because its buggy. I tried to fig...
Arun SS

View additional questions