Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error module 'tablib.formats._xls' has no attribute 'title'

Tags:

django

I have an issue in django, after click in import button in django admin site. This is my code code in admin.py

from django.contrib import admin
from .models import Person

@admin.register(Person)
class PersonAdmin(ImportExportModelAdmin):
    pass

in models.py

from django.db import models
from django.conf import settings
from import_export.admin import ImportMixin

class Person(models.Model):
    name = models.CharField(max_length=30)
    email = models.EmailField(blank=True)
    birth_date = models.DateField()
    location = models.CharField(max_length=100, blank=True)

Error Image

like image 600
Dinh Truong Anh Phuong Avatar asked Jan 28 '26 01:01

Dinh Truong Anh Phuong


1 Answers

I just faced the same issue, and solved it after wasting 4 hours...

Solution

Check the version of tablib and django-import-export that you're using. Django-import-export 1.x only supports tablib version is up to 0.14.0.

You can install a specific version of tablib in pip using

pip install tablib==0.14.0

Alternatively, upgrade your django-import-export to a more recent version (2.x), where this incompatibility is fixed.

Explanation

Very recently, tablib upgraded to 1.0.0, during which the format class has changed. Now, each file type (e.g. xlsx) is a class within the module. django-import-export still expects the file types to be written in the old way, causing the error you see: no attribute 'title'.

like image 76
sijie123 Avatar answered Jan 29 '26 15:01

sijie123



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!