Hello,
have a website on pythonanywhere.com and I need to integrate django-import-export and django-modeltranslation in admin.py and did as below in admin.py
from import_export.admin import ImportExportModelAdmin
from django.contrib import admin
from .models import Brand
from modeltranslation.admin import TranslationAdmin
Register your models here.
class BrandTranslationAdmin(TranslationAdmin):
pass # You can add any further customization for translations here
@admin.register(Brand)
class BrandAdmin(ImportExportModelAdmin, BrandTranslationAdmin):
list_display = ('name_en', 'company_bio_en', 'logo',)
list_filter = ('name_en', )
search_fields = ('name_en', 'company_bio_en')
prepopulated_fields = {'slug': ('name_en',)}
ordering = ('name_en', )
def __init__(self, *args, **kwargs):
super(BrandAdmin, self).__init__(*args, **kwargs)
# Adjust the fields for import/export if needed
self.resource_class.fields = ['name_en', 'company_bio_en', 'logo'] # Example
but it causes the website give:
Something went wrong
Something went wrong while trying to load this website; please try again later.
If it is your site, you should check your logs to determine what the problem is.
There was an error loading your PythonAnywhere-hosted site. There may be a bug in your code.
Error code: Unhandled Exception
I would appreciate your help.