#11678 closed (duplicate)
ValueError when passing an extra parameter in URL
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | contrib.admin | Version: | 1.1 |
| Severity: | Keywords: | ValueError, django.contrib.admin | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Django.contrib.admin produces a ValueError when passing an extra parameter to the URL.
Example:
The edit page for the model 'deelnemer' is: http://localhost:8000/admin/aanmelden/deelnemer/1/
When typing an extra 'a' behind the url (http://localhost:8000/admin/aanmelden/deelnemer/1/a/) a ValueError occurs
Wouldn't it be better for production environments to produce a 404?
Traceback:
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/aanmelden/deelnemer/1/a/
Django Version: 1.1
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'skievent.aanmelden']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')
Traceback:
File "/Library/Python/2.5/site-packages/django/core/handlers/base.py" in get_response
92. response = callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py" in root
490. return self.model_page(request, *url.split('/', 2))
File "/Library/Python/2.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py" in model_page
509. return admin_obj(request, rest_of_url)
File "/Library/Python/2.5/site-packages/django/contrib/admin/options.py" in __call__
1098. return self.change_view(request, unquote(url))
File "/Library/Python/2.5/site-packages/django/db/transaction.py" in _commit_on_success
240. res = func(*args, **kw)
File "/Library/Python/2.5/site-packages/django/contrib/admin/options.py" in change_view
793. obj = self.queryset(request).get(pk=unquote(object_id))
File "/Library/Python/2.5/site-packages/django/db/models/query.py" in get
299. clone = self.filter(*args, **kwargs)
File "/Library/Python/2.5/site-packages/django/db/models/query.py" in filter
498. return self._filter_or_exclude(False, *args, **kwargs)
File "/Library/Python/2.5/site-packages/django/db/models/query.py" in _filter_or_exclude
516. clone.query.add_q(Q(*args, **kwargs))
File "/Library/Python/2.5/site-packages/django/db/models/sql/query.py" in add_q
1675. can_reuse=used_aliases)
File "/Library/Python/2.5/site-packages/django/db/models/sql/query.py" in add_filter
1614. connector)
File "/Library/Python/2.5/site-packages/django/db/models/sql/where.py" in add
56. obj, params = obj.process(lookup_type, value)
File "/Library/Python/2.5/site-packages/django/db/models/sql/where.py" in process
269. params = self.field.get_db_prep_lookup(lookup_type, value)
File "/Library/Python/2.5/site-packages/django/db/models/fields/__init__.py" in get_db_prep_lookup
210. return [self.get_db_prep_value(value)]
File "/Library/Python/2.5/site-packages/django/db/models/fields/__init__.py" in get_db_prep_value
361. return int(value)
Exception Type: ValueError at /admin/aanmelden/deelnemer/1/a/
Exception Value: invalid literal for int() with base 10: '1/a'
Thanks,
Kevin
Change History (5)
comment:1 by , 16 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
comment:2 by , 16 years ago
| Resolution: | duplicate |
|---|---|
| Status: | closed → reopened |
this may not be a duplicate for #3785.
as some of the auto-complete widgets for ForeginKeyField are using url like "/app/model/search..."
in which the url is responded by ModelAdmin's call as follow.
# forward request by url
def __call__(self, request, url):
if url is None:
pass
elif url == 'search':
return auto_complete(request)
return super(MyModelAdmin, self).__call__(request, url)
In Django 1.0.2, this works fine with the call request forward. But in 1.1, above exception raised.
follow-up: 4 comment:3 by , 16 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | reopened → closed |
What you've just said is orthagonal to the problem the reporter hsa. If you believe there is a different bug please file a new ticket, this one is a duplicate.
follow-up: 5 comment:4 by , 16 years ago
Replying to Alex:
What you've just said is orthagonal to the problem the reporter hsa. If you believe there is a different bug please file a new ticket, this one is a duplicate.
Ok, I just fixed how Django1.1 forward urls ... using the new get_urls(self) documented on http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-methods
The old codes should be updated to use get_urls instead of call like...
def get_urls(self):
from django.conf.urls.defaults import *
urls = super(MyModelAdmin, self).get_urls()
my_urls = patterns('',
(r'search', auto_complete),
)
return my_urls + urls
comment:5 by , 16 years ago
Replying to mr.kschan@gmail.com:
Please open a new ticket for this problem rather than continuing to post snippets of info and fix possibilities here. Posting such information to closed tickets is likely going to result in the information getting lost. A new ticket that fully describes the problem and how to recreate it, with a proper patch, would be much more useful.
#3785 is already open for this general problem.