Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#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: UI/UX:


Django.contrib.admin produces a ValueError when passing an extra parameter to the URL.
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?



Request Method: GET
Request URL: http://localhost:8000/admin/aanmelden/deelnemer/1/a/
Django Version: 1.1
Python Version: 2.5.1
Installed Applications:
Installed Middleware:

File "/Library/Python/2.5/site-packages/django/core/handlers/" in get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/" in root
  490.                 return self.model_page(request, *url.split('/', 2))
File "/Library/Python/2.5/site-packages/django/views/decorators/" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/" in model_page
  509.         return admin_obj(request, rest_of_url)
File "/Library/Python/2.5/site-packages/django/contrib/admin/" in __call__
  1098.             return self.change_view(request, unquote(url))
File "/Library/Python/2.5/site-packages/django/db/" in _commit_on_success
  240.                 res = func(*args, **kw)
File "/Library/Python/2.5/site-packages/django/contrib/admin/" in change_view
  793.             obj = self.queryset(request).get(pk=unquote(object_id))
File "/Library/Python/2.5/site-packages/django/db/models/" in get
  299.         clone = self.filter(*args, **kwargs)
File "/Library/Python/2.5/site-packages/django/db/models/" in filter
  498.         return self._filter_or_exclude(False, *args, **kwargs)
File "/Library/Python/2.5/site-packages/django/db/models/" in _filter_or_exclude
  516.             clone.query.add_q(Q(*args, **kwargs))
File "/Library/Python/2.5/site-packages/django/db/models/sql/" in add_q
  1675.                             can_reuse=used_aliases)
File "/Library/Python/2.5/site-packages/django/db/models/sql/" in add_filter
  1614.                 connector)
File "/Library/Python/2.5/site-packages/django/db/models/sql/" in add
  56.                 obj, params = obj.process(lookup_type, value)
File "/Library/Python/2.5/site-packages/django/db/models/sql/" in process
  269.                 params = self.field.get_db_prep_lookup(lookup_type, value)
File "/Library/Python/2.5/site-packages/django/db/models/fields/" in get_db_prep_lookup
  210.             return [self.get_db_prep_value(value)]
File "/Library/Python/2.5/site-packages/django/db/models/fields/" 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'



Change History (5)

comment:1 Changed 8 years ago by Karen Tracey

Resolution: duplicate
Status: newclosed

#3785 is already open for this general problem.

comment:2 Changed 8 years ago by mr.kschan@…

Resolution: duplicate
Status: closedreopened

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:
    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.

comment:3 Changed 8 years ago by Alex Gaynor

Resolution: duplicate
Status: reopenedclosed

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.

comment:4 in reply to:  3 ; Changed 8 years ago by mr.kschan@…

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

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 in reply to:  4 Changed 7 years ago by Karen Tracey

Replying to

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.

Note: See TracTickets for help on using tickets.
Back to Top