#20795: Weird queryset behaviour and count() method
-------------------------------------+-------------------------------------
Reporter: maa@… | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.5
(models, ORM) | Resolution:
Severity: Release blocker | Triage Stage:
Keywords: count queryset | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by maa@…):
I dont have a unicode method.
len(EmailChangeLog.objects.all()) fails with AttributeError: 'int' object
has no attribute 'username'
traceback :
{{{
/home/maa/.virtualenvs/django_myproject/local/lib/python2.7/site-
packages/django/db/models/query.pyc in __len__(self)
88 self._result_cache = list(self._iter)
89 else:
---> 90 self._result_cache = list(self.iterator())
91 elif self._iter:
92 self._result_cache.extend(self._iter)
/home/maa/.virtualenvs/django_myproject/local/lib/python2.7/site-
packages/django/db/models/query.pyc in iterator(self)
309 obj = model_cls(**dict(zip(init_list,
row_data)))
310 else:
--> 311 obj = model(*row_data)
312
313 # Store the source database of the object
/home/maa/PycharmProjects/django_myproject/my_home/models.pyc in
__init__(self, user, *args, **kwargs)
41 super(EmailChangeLog, self).__init__(self, *args,
**kwargs)
42 salt = hashlib.sha1(str(random.random())).hexdigest()[:5]
---> 43 username = user.username
44 if isinstance(username, unicode):
45 username = username.encode('utf-8')
AttributeError: 'int' object has no attribute 'username'
}}}
My manager has only one method and did n"t use it.
I have only one model and I already gave my 'models.py' code here is a
pastebin : http://pastebin.com/0qSkeveT
Their is no view code involved, the same weird behaviour happens with the
'manage.py shell_plus' command.
Also I am using postgresql 8.4.17 on ubuntu 12.04 LTS, thanks for your
support.
--
Ticket URL: <https://code.djangoproject.com/ticket/20795#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/074.4bd03d6d6809ecec3b9c9c3e2e84758d%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.