Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with queryset.values #129

Open
brykov93 opened this issue Jul 19, 2024 · 0 comments
Open

Error with queryset.values #129

brykov93 opened this issue Jul 19, 2024 · 0 comments

Comments

@brykov93
Copy link

brykov93 commented Jul 19, 2024

Hi.
I needed to display data after applying queryset.values. As a result, instead of data, ??? in all columns.
Model:

class StudyUploadLog(models.Model):
study_instance_uid = models.CharField(max_length=150, verbose_name='Study Instance UID')
patient = models.CharField(max_length=150, verbose_name='Patient')
instance_uid = models.CharField(max_length=150, verbose_name='Instance UID')
upload_date = models.DateTimeField(verbose_name='Upload time')
completed = models.BooleanField(verbose_name='Completed', default=False)

View:

class UploadingStudies(AjaxDatatableView):
model = StudyUploadLog
title = 'Лог получения исследований'
#initial_order = [["upload_date", "desc"], ]
length_menu = [[50, 100, -1], [50, 100, 'Все']]
search_values_separator = '+'
disable_queryset_optimization_only = True
column_defs = [
{'name': 'id', 'visible': False, 'searchable': False, },
{'name': 'patient', 'title': 'Пациент', 'searchable': False, 'visible': True},
{'name': 'study_instance_uid', 'title': 'Идентификатор исследования', 'searchable': False, 'visible': True},
# {'name': 'progress', 'title': 'Прогресс', 'searchable': False, 'visible': True},
{'name': 'images_count', 'title': 'Количество файлов', 'searchable': False, 'visible': True},
{'name': 'start_date', 'title': 'Время начала приема', 'searchable': False, 'visible': True},
{'name': 'end_date', 'title': 'Время окончания приема', 'searchable': False, 'visible': True},
{'name': 'completed', 'title': 'Прием окончен', 'searchable': False, 'visible': True, 'boolean': True,},
]
def get_initial_queryset(self, request=None):
queryset = super().get_initial_queryset(request=request)
queryset = (queryset.values('patient', 'study_instance_uid', 'completed')
.annotate(images_count=Count('instance_uid'),
id=Max('id'),
start_date=Min('upload_date'),
end_date=Max('upload_date')))
return queryset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant