Django-Unicorn: django_unicorn.errors.ComponentModuleLoadError: Не удалось загрузить компонентный модуль 'views_unicorn'
У меня есть Django-приложение, где мне нужно частичное обновление, и я хотел реализовать django-unicorn. Локально это работает, но на сервере я получаю эту ошибку.
На сервере работает gunicorn. Я пытался следовать настройкам и основывался на них в документации здесь: https://www.django-unicorn.com/docs/direct-view/#template-requirements
Traceback (most recent call last):
File "/home/django/.local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/django/.local/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.10/dist-packages/sentry_sdk/integrations/django/views.py", line 84, in sentry_wrapped_callback
return callback(request, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/home/django/.local/lib/python3.10/site-packages/django_unicorn/decorators.py", line 16, in timed
return func(*args, **kwargs)
File "/home/django/.local/lib/python3.10/site-packages/django_unicorn/views/__init__.py", line 49, in wrapped_view
return view_func(*args, **kwargs)
File "/home/django/.local/lib/python3.10/site-packages/django/utils/decorators.py", line 134, in _wrapper_view
response = view_func(request, *args, **kwargs)
File "/home/django/.local/lib/python3.10/site-packages/django/utils/decorators.py", line 134, in _wrapper_view
response = view_func(request, *args, **kwargs)
File "/home/django/.local/lib/python3.10/site-packages/django/views/decorators/http.py", line 43, in inner
return func(request, *args, **kwargs)
File "/home/django/.local/lib/python3.10/site-packages/django_unicorn/views/__init__.py", line 555, in message
json_result = _handle_component_request(request, component_request)
File "/home/django/.local/lib/python3.10/site-packages/django_unicorn/views/__init__.py", line 408, in _handle_component_request
return _process_component_request(request, component_request)
File "/home/django/.local/lib/python3.10/site-packages/django_unicorn/views/__init__.py", line 86, in _process_component_request
component = UnicornView.create(
File "/usr/local/lib/python3.10/dist-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/home/django/.local/lib/python3.10/site-packages/django_unicorn/decorators.py", line 16, in timed
return func(*args, **kwargs)
File "/home/django/.local/lib/python3.10/site-packages/django_unicorn/components/unicorn_view.py", line 927, in create
raise ComponentModuleLoadError(message, locations=locations)
django_unicorn.errors.ComponentModuleLoadError: The component module 'views_unicorn' could not be loaded.
Моя форма выглядит следующим образом:
<form unicorn:submit.prevent="scan_ean">
<div class="form-group">
<div class="input-group">
<input
id="scanned-ean"
class="textinput form-control"
name="scanned-ean" placeholder="EAN Number"
autofocus
unicorn:model.defer="ean_number"
unicorn:keyup.escape="ean_number=''"
/>
<span class="input-group-btn" style="width:0;"></span>
<input id="scanned-ean-quantity-overide"
class="textinput form-control"
name="scanned-ean-quantity-overide"
placeholder="QTY Override"
unicorn:model.defer="scan_quantity_overide"
unicorn:keyup.escape="scan_quantity_overide=''"
/>
</div>
</div>
<button unicorn:click="scan_ean">Scan</button>
</form>
Тогда мое мнение:
class OrderPickListView(UnicornView):
order: Order
template_name = 'pim/order_list_picking.html'
ean_number: str
scan_quantity_overide: str
scan_error: str
order_id: int
def mount(self):
self.ean_number = ''
self.scan_quantity_overide = ''
self.scan_error = ''
self.order_id = self.kwargs['order_id']
self.order = Order.objects.get(id=self.order_id)
def scan_ean(self):
self.scan_error='test'
Думаю, больше всего меня беспокоит то, что localhost на docker с почти такой же настройкой работает нормально.