Some details, and debugging comments and solution questions at the bottom of the OP:
[08/Sep/2022 16:00:25] "GET /cms/home/venue/reorder/3/?after=2 HTTP/1.1" 500 74627
Internal Server Error: /cms/home/venue/reorder/3/
Traceback (most recent call last):
File "/home/vscode/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/vscode/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/vscode/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.9/site-packages/django/views/decorators/cache.py", line 62, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/home/vscode/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.9/site-packages/wagtail/admin/urls/__init__.py", line 161, in wrapper
return view_func(request, *args, **kwargs)
File "/home/vscode/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.9/site-packages/wagtail/admin/auth.py", line 182, in decorated_view
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/home/vscode/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.9/site-packages/wagtailorderable/modeladmin/mixins.py", line 196, in reorder_view
qs.update(**{self.sort_order_field: update_value})
UnboundLocalError: local variable 'update_value' referenced before assignment
Internal Server Error: /cms/home/venue/reorder/3/
Traceback (most recent call last):
File "/home/vscode/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/vscode/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/vscode/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.9/site-packages/django/views/decorators/cache.py", line 62, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/home/vscode/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.9/site-packages/wagtail/admin/urls/__init__.py", line 161, in wrapper
return view_func(request, *args, **kwargs)
File "/home/vscode/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.9/site-packages/wagtail/admin/auth.py", line 182, in decorated_view
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/home/vscode/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.9/site-packages/wagtailorderable/modeladmin/mixins.py", line 196, in reorder_view
qs.update(**{self.sort_order_field: update_value})
UnboundLocalError: local variable 'update_value' referenced before assignment
So my question is: how are we meant to initialise the database with an arbitrary sort order, so that the ordering function works?
Some details, and debugging comments and solution questions at the bottom of the OP:
Packages
wagtail-orderable 1.1.0
wagtail 3.0.3
django 4.0.7
Full stack error
Relevant code
wagtail-orderable/wagtailorderable/modeladmin/mixins.py
Lines 178 to 196 in 4869d35
Debugging
Printing
print(position, old_position)in the above code prints0, 0.Looking at my database, I see that the
sort_ordercolumn for all Venue records is NULL, and this is why position and old_position and so on are defaulting to 0.So my question is: how are we meant to initialise the database with an arbitrary sort order, so that the ordering function works?