---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
<ipython-input-1-b1fc61315659> in <module>()
---> 47 print(a)
/Users/martijntenhoor/projects/bluebi/rms-drf-api/virtual/lib/python3.5
/site-packages/django/db/models/query.py in __repr__(self)
224
225 def __repr__(self):
--> 226 data = list(self[:REPR_OUTPUT_SIZE + 1])
227 if len(data) > REPR_OUTPUT_SIZE:
228 data[-1] = "...(remaining elements truncated)..."
/Users/martijntenhoor/projects/bluebi/rms-drf-api/virtual/lib/python3.5
/site-packages/django/db/models/query.py in __iter__(self)
248 - Responsible for turning the rows into model
objects.
249 """
--> 250 self._fetch_all()
251 return iter(self._result_cache)
252
/Users/martijntenhoor/projects/bluebi/rms-drf-api/virtual/lib/python3.5
/site-packages/django/db/models/query.py in _fetch_all(self)
1116 def _fetch_all(self):
1117 if self._result_cache is None:
-> 1118 self._result_cache = list(self._iterable_class(self))
1119 if self._prefetch_related_lookups and not
self._prefetch_done:
1120 self._prefetch_related_objects()
/Users/martijntenhoor/projects/bluebi/rms-drf-api/virtual/lib/python3.5
/site-packages/django/db/models/query.py in __iter__(self)
104 names = extra_names + field_names + annotation_names
105
--> 106 for row in compiler.results_iter():
107 yield dict(zip(names, row))
108
/Users/martijntenhoor/projects/bluebi/rms-drf-api/virtual/lib/python3.5
/site-packages/django/db/models/sql/compiler.py in results_iter(self,
results)
840 for row in rows:
841 if converters:
--> 842 row = self.apply_converters(row, converters)
843 yield row
844
/Users/martijntenhoor/projects/bluebi/rms-drf-api/virtual/lib/python3.5
/site-packages/django/db/models/sql/compiler.py in apply_converters(self,
row, converters)
825 value = row[pos]
826 for converter in convs:
--> 827 value = converter(value, expression,
self.connection, self.query.context)
828 row[pos] = value
829 return tuple(row)
/Users/martijntenhoor/projects/bluebi/rms-drf-api/virtual/lib/python3.5
/site-packages/django/db/backends/mysql/operations.py in
convert_datetimefield_value(self, value, expression, connection, context)
237 if value is not None:
238 if settings.USE_TZ:
--> 239 value = timezone.make_aware(value,
self.connection.timezone)
240 return value
241
/Users/martijntenhoor/projects/bluebi/rms-drf-api/virtual/lib/python3.5
/site-packages/django/utils/timezone.py in make_aware(value, timezone,
is_dst)
283 if hasattr(timezone, 'localize'):
284 # This method is available for pytz time zones.
--> 285 return timezone.localize(value, is_dst=is_dst)
286 else:
287 # Check that we won't overwrite the timezone of an aware
datetime.
/Users/martijntenhoor/projects/bluebi/rms-drf-api/virtual/lib/python3.5
/site-packages/pytz/__init__.py in localize(self, dt, is_dst)
225 '''Convert naive time to local time'''
226 print(dt)
--> 227 if dt.tzinfo is not None:
228 raise ValueError('Not naive datetime (tzinfo is
already set)')
229 return dt.replace(tzinfo=self)
AttributeError: 'int' object has no attribute 'tzinfo'
--
Ticket URL: <https://code.djangoproject.com/ticket/28827>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
New description:
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/28827#comment:1>
Old description:
> The generated query works fine in MySQL, guess Django still thinks the
New description:
Query with ExtractHour and calculation like
"values(minutes=(ExtractHour('dt_start') * 60))" gives an pytz error:
AttributeError: 'int' object has no attribute 'tzinfo'
The generated query works fine in MySQL, guess Django still thinks the
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/28827#comment:2>
* status: new => closed
* resolution: => fixed
Comment:
I guess you meant to use `QuerySet.annotate()` instead of `values()` in
the description since the latter doesn't accept a `minutes` keyword
argument.
Based on my testing of that, it seems this is fixed in Django 2.0 by
504ce3914fa86a58f29f5369a806f3fe56a0d59a. If not, please reopen with more
explicit steps (model/queryset) to reproduce.
--
Ticket URL: <https://code.djangoproject.com/ticket/28827#comment:3>