Open zN3utr4l opened 11 months ago
Environment: Request Method: GET Request URL: http://127.0.0.1:7000/admin/huey_monitor/taskmodel/e2fe16e4-2d57-45b5-95ae-db99b01b4659/change/ Django Version: 3.2.21 Python Version: 3.9.18 Installed Applications: [... 'bx_django_utils', 'huey_monitor', ..] Traceback (most recent call last): File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\contrib\admin\options.py", line 710, in get_form return modelform_factory(self.model, **defaults) File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\forms\models.py", line 563, in modelform_factory return type(form)(class_name, (form,), form_class_attrs) File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\forms\models.py", line 276, in __new__ raise FieldError(message) During handling of the above exception (Unknown field(s) (task_hierarchy_info, human_progress_string) specified for TaskModel), another exception occurred: File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\contrib\admin\options.py", line 616, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\contrib\admin\sites.py", line 232, in inner return view(request, *args, **kwargs) File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\contrib\admin\options.py", line 1660, in change_view return self.changeform_view(request, object_id, form_url, extra_context) File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper return bound_method(*args, **kwargs) File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\contrib\admin\options.py", line 1540, in changeform_view return self._changeform_view(request, object_id, form_url, extra_context) File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\contrib\admin\options.py", line 1574, in _changeform_view ModelForm = self.get_form( File "D:\Users\x\mambaforge\envs\production\lib\site-packages\django\contrib\admin\options.py", line 712, in get_form raise FieldError( Exception Type: FieldError at /admin/huey_monitor/taskmodel/e2fe16e4-2d57-45b5-95ae-db99b01b4659/change/ Exception Value: Unknown field(s) (task_hierarchy_info, human_progress_string) specified for TaskModel. Check fields/fieldsets/exclude attributes of class CustomTaskModelAdmin.
from django.contrib import admin from huey_monitor.models import TaskModel, SignalInfoModel from huey_monitor.admin import TaskModelAdmin, SignalInfoModelAdmin admin.site.unregister(TaskModel) admin.site.unregister(SignalInfoModel) class CustomTaskModelAdmin(TaskModelAdmin): def has_view_permission(self, request, obj=None): return request.user.is_superuser def has_delete_permission(self, request, obj=None): return request.user.is_superuser def has_change_permission(self, request, obj=None): return request.user.is_superuser def has_add_permission(self, request, obj=None): return request.user.is_superuser def has_module_permission(self, request): return request.user.is_superuser admin.site.register(TaskModel, CustomTaskModelAdmin) class CustomSignalInfoModelAdmin(SignalInfoModelAdmin): def has_view_permission(self, request, obj=None): return request.user.is_superuser def has_delete_permission(self, request, obj=None): return request.user.is_superuser def has_change_permission(self, request, obj=None): return request.user.is_superuser def has_add_permission(self, request, obj=None): return request.user.is_superuser def has_module_permission(self, request): return request.user.is_superuser admin.site.register(SignalInfoModel, CustomSignalInfoModelAdmin)
admin.py