Since datetimes returns a new QuerySet, I expected that code would work,
but I stumbled on this error message:
{{{
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/vagrant/.virtualenvs/awesomeapp/local/lib/python2.7/site-
packages/django/db/models/query.py", line 116, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "/home/vagrant/.virtualenvs/awesomeapp/local/lib/python2.7/site-
packages/django/db/models/query.py", line 141, in __iter__
self._fetch_all()
File "/home/vagrant/.virtualenvs/awesomeapp/local/lib/python2.7/site-
packages/django/db/models/query.py", line 966, in _fetch_all
self._result_cache = list(self.iterator())
File "/home/vagrant/.virtualenvs/awesomeapp/local/lib/python2.7/site-
packages/django/db/models/sql/compiler.py", line 1130, in results_iter
for rows in self.execute_sql(MULTI):
File "/home/vagrant/.virtualenvs/awesomeapp/local/lib/python2.7/site-
packages/django/db/models/sql/compiler.py", line 775, in execute_sql
sql, params = self.as_sql()
File "/home/vagrant/.virtualenvs/awesomeapp/local/lib/python2.7/site-
packages/django/db/models/sql/compiler.py", line 133, in as_sql
grouping, gb_params = self.get_grouping(having_group_by,
ordering_group_by)
File "/home/vagrant/.virtualenvs/awesomeapp/local/lib/python2.7/site-
packages/django/db/models/sql/compiler.py", line 586, in get_grouping
if sql not in seen:
UnboundLocalError: local variable 'sql' referenced before assignment
}}}
So I took a look at the source code:
https://github.com/django/django/blob/1.7.3/django/db/models/sql/compiler.py#L586
And if I read it correctly: if the condition in line 582 is sufficed, then
the var 'sql' is indeed unassigned in the line 586.
I'm using python 2.7.6 and Django 1.7.3
The database is MySQL 5.5
--
Ticket URL: <https://code.djangoproject.com/ticket/24222>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
This is fixed in 1.8, and was fixed by
[https://github.com/django/django/commit/cbb5cdd this commit].
--
Ticket URL: <https://code.djangoproject.com/ticket/24222#comment:1>
* status: new => closed
* resolution: => fixed
--
Ticket URL: <https://code.djangoproject.com/ticket/24222#comment:2>