#4431 (@dd.chooser decorator raises Exception on slave tables that uses custom get_master_instance method)
by Sharif Mehedi · in Developers · assigned to Sharif Mehedi
Summary
Internal Server Error: /choices/medico/SpecialtiesByUser/specialty
Traceback (most recent call last):
File "/home/blurry/lino/env/repositories/lino/lino/utils/choosers.py", line 370, in get_request_choices
kw[tbl.master_field.name] = master.objects.get(pk=pk)
File "/home/blurry/lino/env/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/blurry/lino/env/lib/python3.8/site-packages/django/db/models/query.py", line 439, in get
raise self.model.DoesNotExist(
lino_medico.lib.contacts.models.Worker.DoesNotExist: Worker matching query does not exist.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/blurry/lino/env/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/blurry/lino/env/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/blurry/lino/env/lib/python3.8/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, *args, **kwargs)
File "/home/blurry/lino/env/lib/python3.8/site-packages/django/views/generic/base.py", line 101, in dispatch
return handler(request, *args, **kwargs)
File "/home/blurry/lino/env/repositories/react/lino_react/react/views.py", line 268, in get
qs, row2dict = choices_for_field(rpt.request(request=request), rpt, field)
File "/home/blurry/lino/env/repositories/lino/lino/core/fields.py", line 1506, in choices_for_field
qs = chooser.get_request_choices(ar, holder)
File "/home/blurry/lino/env/repositories/lino/lino/utils/choosers.py", line 375, in get_request_choices
raise Exception("There's no %s with primary key %r" %
Exception: There's no Worker with primary key '6'
[13/Feb/2022 08:29:59] "GET /choices/medico/SpecialtiesByUser/specialty?mk=6&mt=5&physician&query=&start=0 HTTP/1.1" 500 108548
Children
Comments
- 4 years, 8 months ago by Sharif Mehedi about #4431 (@dd.chooser decorator raises Exception on slave tables that uses custom get_master_instance method) : To fix this, I put code on Chooser.get_request_choices method to check if 'get_master_instance' is in tbl.__dict__ and if so then call tbl.get_master_instance, otherwise do the older code. See [url gitlab.com/lino-framework/lino/-/commit/70fb16ae99976430f2728d622584b85213f42250 commit].