Opened 12 years ago
Closed 12 years ago
#20217 closed Bug (invalid)
query model using `filter` or `get` occur ValueError: invalid literal for int() with base 10
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
class User(models.Model):
identifier=models.CharField(max_length=128, unique=True, db_index=True)
..........
..........
class Token(models.Model):
user = models.ForeignKey("User", related_name="Tokens")
token_string = models.CharField(max_length=128, unique=True, db_index=True)
while I already have a tk(<Token object>),I run this:
user = User.objects.filter(id=tk.user_id) if user: user = user[0]
it cause the ValueError: invalid literal for int() with base 10:
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 113, in nonzero
iter(self).next()
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 107, in _result_iter
self._fill_cache()
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 772, in _fill_cache
self._result_cache.append(self._iter.next())
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 273, in iterator
for row in compiler.results_iter():
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 680, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 86, in execute
return self.cursor.execute(query, args)
File "build/bdist.linux-x86_64/egg/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "build/bdist.linux-x86_64/egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
ValueError: invalid literal for int() with base 10: '\xd9'
but it disappeared when I restart my project, but a couple of days while running, it occured again
How does it happened and any solutions?
If you've got a question about how to fix an error, please post to the Django-users mailing list. Trac is a place where we log known bugs so we can make sure they're not forgotten.