我安装了 django-simple-history
但它不起作用。
我尝试了python manage.py makemigrations
,但
速度低于错误。像 AttributeError: type object 'SimpleHistoryAdmin' has no attribute '_meta' 我想在 django-admin 中查看历史记录。
怎么了?????
Traceback (most recent call last):
class AccountClassificationAdmin(admin.ModelAdmin):
File "/root/miniconda3/envs/gdaj/lib/python3.9/site-packages/django/contrib/admin/decorators.py", line 100, in _model_admin_wrapper
admin_site.register(models, admin_class=admin_class)
File "/root/miniconda3/envs/gdaj/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 113, in register
if model._meta.abstract:
AttributeError: type object 'SimpleHistoryAdmin' has no attribute '_meta'
# settings.py
i added
'simple_history', at installed_app
'simple_history.middleware.HistoryRequestMiddleware', at middleware
# models.py
class PayHistory(TimeStampedModel):
package_patient = models.CharField(max_length=10, null=False)
package_classification = models.CharField(max_length=10, null=False)
history = HistoricalRecords()
class PayHistoryChange(TimeStampedModel):
payhistory = models.ForeignKey(PayHistory, on_delete=models.CASCADE, null=False)
history = HistoricalRecords()
# admin.py
@admin.register(PayHistory)
class PayHistoryAdmin(SimpleHistoryAdmin):
list_display = (
"package_patient",
"package_classification"
)
i tried admin.site.register(PayHistory, PayHistoryAdmin)
but it's also not working