ich so einige Daten in Django zu filtern versuchen:Django: unable repr für die Klasse ‚django.db.models.query.datetimequeryset‘ bekommen
MyModel.objects.filter(tense="future").values_list('date_updated').datetimes('date_updateded', 'hour').annotate(updated_count=Count('name'))
Ich verwende PyCharm für das Debuggen und PyCharm zeigt:
Django: unable to get repr for class 'django.db.models.query.datetimequeryset'
Und ich dieses auf meiner Ansicht (Browser):
UnboundLocalError at /myview/
local variable 'sql' referenced before assignment
Wie kann ich dieses Problem beheben?
(Ich versuche, basierend auf ‚angespannt‘, bekommt die Zeit innerhalb einer Stunde Pause zu filtern, und die Namen zählen, eine Ausgabe so etwas wie diese (Datum, updated_count) erwartet)
EDIT, hinzugefügt Traceback:
Traceback:
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response 111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/django/contrib/auth/decorators.py" in _wrapped_view 21. return view_func(request, *args, **kwargs)
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/django/views/decorators/csrf.py" in wrapped_view 57. return view_func(*args, **kwargs)
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/django/views/generic/base.py" in view 69. return self.dispatch(request, *args, **kwargs)
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/rest_framework/views.py" in dispatch 452. response = self.handle_exception(exc)
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/rest_framework/views.py" in dispatch 449. response = handler(request, *args, **kwargs)
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/rest_framework/decorators.py" in handler 50. return func(*args, **kwargs)
File "/home/ahmad/redvenv/redcloud/redcloud/docServer/docServer/api_views.py" in monitoring 456. data = ChartData.get_chart_data()
File "/home/ahmad/redvenv/redcloud/redcloud/docServer/docServer/api_views.py" in get_chart_data 445. data['onAudit'] = ObjectNode.on_session_data()
File "/home/ahmad/redvenv/redcloud/redcloud/docServer/docServer/models/graph.py" in on_session_data 176. return Audit.chart_data_formatter(loginCount)
File "/home/ahmad/redvenv/redcloud/redcloud/docServer/docServer/models/monitoring.py" in chart_data_formatter 34. list_of_data_items = [list(elem) for elem in chartData]
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/django/db/models/query.py" in __iter__ 141. self._fetch_all()
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/django/db/models/query.py" in _fetch_all 966. self._result_cache = list(self.iterator())
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in results_iter 1130. for rows in self.execute_sql(MULTI):
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in execute_sql 775. sql, params = self.as_sql()
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in as_sql 133. grouping, gb_params = self.get_grouping(having_group_by, ordering_group_by)
File "/home/ahmad/redvenv/redcloud/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in get_grouping 586. if sql not in seen:
Exception Type: UnboundLocalError at /myview/
Exception Value: local variable 'sql' referenced before assignment
Bitte zeigen Sie die vollständige Traceback. – Alasdair
@Alasdair, aktualisiert. –