﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18407	Validation error messages should support unicode params	znotdead	Claude Paroz	"Does not provided case when object_id is Unicode[[BR]]

Example:
http://localhost:8000/admin/auth/user/%D1%8B%D0%B2%D0%B0%D1%8B%D0%B2/

Gives error:

{{{
UnicodeEncodeError at /admin/auth/user/ываыв/

'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)

Request Method: 	GET
Request URL: 	http://localhost:8000/admin/auth/user/%D1%8B%D0%B2%D0%B0%D1%8B%D0%B2/
Django Version: 	1.4
Exception Type: 	UnicodeEncodeError
Exception Value: 	

'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)

Exception Location: 	/media/disk/env/django14/lib/python2.6/site-packages/django/db/models/fields/__init__.py in to_python, line 528
Python Executable: 	/media/disk/env/django14/bin/python
Python Version: 	2.6.7
}}}

Exception happened on AutoField(Field) to_python method:
            
{{{
msg = self.error_messages['invalid'] % str(value)
}}}

And so we have 500 but not 404.


{{{
/media/disk/env/django14/lib/python2.6/site-packages/django/contrib/admin/options.py in get_object

            Returns an instance matching the primary key provided. ``None``  is

            returned if no match is found (or the object_id failed validation

            against the primary key field).

            """"""

            queryset = self.queryset(request)

            model = queryset.model

            try:

                object_id = model._meta.pk.to_python(object_id)

    ...

                return queryset.get(pk=object_id)

            except (model.DoesNotExist, ValidationError):

                return None

        def get_changelist_form(self, request, **kwargs):

            """"""

▶ Local vars
/media/disk/env/django14/lib/python2.6/site-packages/django/db/models/fields/__init__.py in to_python

        def to_python(self, value):

            if value is None:

                return value

            try:

                return int(value)

            except (TypeError, ValueError):

                msg = self.error_messages['invalid'] % str(value)

    ...

                raise exceptions.ValidationError(msg)

        def validate(self, value, model_instance):

            pass

        def get_prep_value(self, value):

▼ Local vars
Variable 	Value
self 	<django.db.models.fields.AutoField: id>
value 	u'\u044b\u0432\u0430\u044b\u0432'
}}}

"	Bug	closed	Database layer (models, ORM)	1.4	Normal	fixed	urls pk admin unicode		Accepted	0	0	0	0	0	0
