Why django import export is not working in my django project?

691 Views Asked by At

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
1

There are 1 best solutions below

0
On

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