#10468 closed (invalid)
django/db/models/sql/query.py fails on tuple unpacking
| Reported by: | anonymous | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Other) | Version: | 1.0 |
| Severity: | Keywords: | db sql query.py | |
| Cc: | django-admin --version: 1.0.2 final | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Got the following error:
ValueError at /text/5/
need more than 1 value to unpack
Request Method: GET Request URL: http://localhost:8000/text/5/ Exception Type: ValueError Exception Value:
need more than 1 value to unpack
Exception Location: /var/lib/python-support/python2.5/django/db/models/sql/query.py in add_filter, line 1101
Python Executable: /usr/bin/python
Python Version: 2.5.2
Python Path: ['/media/Daten/Projects/Webproj/evankproj', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/Numeric', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/gst-0.10', '/var/lib/python-support/python2.5', '/usr/lib/python2.5/site-packages/gtk-2.0', '/var/lib/python-support/python2.5/gtk-2.0', '/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode']
With a Model
6 class Text(models.Model):
7 text = models.CharField(max_length=(10 ** 5))
8 date = models.DateTimeField()
With a view
7 def view_text(request, text_id):
8 text = get_object_or_404(Text, text_id)
9 return render_to_response(u"text.html", {u"text": text})
The Following is the output of the development server:
[11/Mar/2009 16:30:39] "GET /text/5 HTTP/1.1" 301 0
[11/Mar/2009 16:30:39] "GET /text/5/ HTTP/1.1" 500 71938
text/5/ works as in the Django Tutorial with polls/\d+ for a poll_id.
Traceback:
Environment:
Request Method: GET
Request URL: http://localhost:8000/text/5/
Django Version: 1.0.2 final
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'evankproj.textapp']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')
Traceback:
File "/var/lib/python-support/python2.5/django/core/handlers/base.py" in get_response
86. response = callback(request, *callback_args, **callback_kwargs)
File "/media/Daten/Projects/Webproj/evankproj/../evankproj/textapp/views.py" in view_text
8. text = get_object_or_404(Text, text_id)
File "/var/lib/python-support/python2.5/django/shortcuts/__init__.py" in get_object_or_404
46. return queryset.get(*args, **kwargs)
File "/var/lib/python-support/python2.5/django/db/models/query.py" in get
303. clone = self.filter(*args, **kwargs)
File "/var/lib/python-support/python2.5/django/db/models/query.py" in filter
489. return self._filter_or_exclude(False, *args, **kwargs)
File "/var/lib/python-support/python2.5/django/db/models/query.py" in _filter_or_exclude
507. clone.query.add_q(Q(*args, **kwargs))
File "/var/lib/python-support/python2.5/django/db/models/sql/query.py" in add_q
1258. can_reuse=used_aliases)
File "/var/lib/python-support/python2.5/django/db/models/sql/query.py" in add_filter
1101. arg, value = filter_expr
Exception Type: ValueError at /text/5/
Exception Value: need more than 1 value to unpack
I didn't find anything relevant in the tickets on a search for the traceback message (tuple unpacking failing).
Change History (3)
comment:1 by , 17 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 17 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
In this example what is text_id? It looks to me that what you meant to do is get_object_or_404(Text, id=text_id) and thus I'm marking as invalid.
comment:3 by , 17 years ago
Yes, meant that. Just didn't see it. But, well, the Traceback looks very confusing and deeply in the hierarchie. Maybe improvable?
Note:
See TracTickets
for help on using tickets.
Please use the preview button.