'Why django import export is not working in my django project?
I am working in django project and I want admin to import data from excel file to database of model Entry. But it is not working properly . here is my admin.py
from django.contrib import admin
from .models import Entry
from import_export.admin import ImportMixin
from .resources import EntryResource
class EntryAdmin(ImportMixin, admin.ModelAdmin):
resource_class = EntryResource
admin.site.register(Entry, EntryAdmin)
the error is : Cannot assign "'vijay'": "Entry.user" must be a "CustomUser" instance.
my csv file:
Id,User,Member,Member Id,Email Address,State,K No,Board,Last Date,Amount
vijay,team,team54f4d,[email protected],rajasthan,5f4d5f4d,jval,
2022-03-13,54451
Solution 1:[1]
Should use the user id it's a foreignkey field so do it's returning the error
Id,User,Member,Member Id,Email Address,State,K No,Board,Last Date,Amount 1,team,team54f4d,[email protected],rajasthan,5f4d5f4d,jval,2022-03-13,54451
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mallu developer |
