Open martinsrudzroga opened 2 years ago
Hi @joeyjurjens, Could you drop a hint where to look for the bug please ? I tried very much but not reaching...Thanks !!
Hi @joeyjurjens, Could you drop a hint where to look for the bug please ? I tried very much but not reaching...Thanks !!
Hi, the issue occurs due to this in the template: https://github.com/django-oscar/django-oscar/blob/master/src/oscar/templates/oscar/dashboard/vouchers/voucher_set_list.html#L39-L41
This is the Python code that belongs to it I think: https://github.com/django-oscar/django-oscar/blob/master/src/oscar/apps/dashboard/vouchers/views.py#L315-L320
I hope that helps!
I had seen the python code(view,models,sort_queryset etc method) earlier. They all seem to be fine. Maybe I am missing something ?
@vallabhtiwari you can replicate by creating an Offer, Voucher set and then try to order by in that view (see image below).
Date created will order fine since it is a database field but others (red) would not since they are computed values. Possible workarounds seems to be turning the QuerySet
into list
and order it or adjust the DB schema and turn those properties into fields and use post_save
hook/signal to populate them. I like the first approach better although I am not that familiar with the code base and how that would impact the performance. There is another approach using extra()
but it is discouraged by Django team and it is mentioned it will be deprecated at some point.
FieldError at /dashboard/vouchers/sets/
Cannot resolve keyword 'num_basket_additions' into field. Choices are: code_length, count, date_created, description, end_datetime, id, name, start_datetime, vouchers
Request Method: GET
Request URL: http://localhost:8000/dashboard/vouchers/sets/?sort=num_basket_additions
Django Version: 4.2.9
Exception Type: FieldError
Exception Value:
Cannot resolve keyword 'num_basket_additions' into field. Choices are: code_length, count, date_created, description, end_datetime, id, name, start_datetime, vouchers
Exception Location: /home/vito/projects/ecommv2/.venv/lib/python3.10/site-packages/django/db/models/sql/query.py, line 1725, in names_to_path
Raised during: oscar.apps.dashboard.vouchers.views.VoucherSetListView
Python Executable: /home/vito/projects/ecommv2/.venv/bin/python
Python Version: 3.10.12
Python Path:
['/home/vito/projects/ecommv2/mysite',
'/usr/lib/python310.zip',
'/usr/lib/python3.10',
'/usr/lib/python3.10/lib-dynload',
'/home/vito/projects/ecommv2/.venv/lib/python3.10/site-packages']
Server time: Mon, 12 Feb 2024 12:54:06 +0200
https://latest.oscarcommerce.com/en-gb/dashboard/vouchers/sets/?sort=num_basket_additions