Description

Hello everyone

There is a mistake in django/newforms/fields.py:

when one uses ChoiceField to select a value from predefined choices it tries to validate selected choice against a list of string values, should be a list of unicode values as it's done in MultipleChoiceField

Without the patch one always gets "Select a valid choice. %s is not one of the available choices." ValidationError.

Hmm, since newforms is unicode country, I guess this is the wrong fix. formfield.choices should contain unicode strings, not bytestrings. IMHO, the bug is rather in formfield() (probably ForeignKey.formfield() ), it should decode the options to unicode during formfield construction, using settings.DEFAULT_CHARSET as encoding. Can you please specify how you created the ChoiceField?

A unit test would be great (it's needed anyway, no matter how this turns out).

clean() always converts value to unicode and then unicode value is compared against list of choices and if this list is not in unicode, this check fails. My patch converts choices list to unicode if needs just for comparing because unicode should be compared against unicode, not bytestrings.

And again: take a look a few lines below my patch, there is absolutely the same code for MultipleChoiceField and it does exactly the same as my patch does

Umm there is a problem with tests: because it touches local (national) environments, it seems I need a new test directory similar to tests/modeltests/model_forms/models.py but with sources in coding: utf-8 or windows-1251. Is that ok ?

Fixed #1015 -- Fixed decorator_from_middleware to return a real decorator even
when arguments are given. This looks a bit ugly, but it's fully backwards
compatible and all the extra work is done at import time, so it shouldn't have
any real performance impact.

Fixed reverse URL lookup using functions when the original URL pattern was a
string. This is now just as fragile as it was prior to [5609], but works in a
few cases that people were relying on, apparently.

Improved syndication feed framework to use RequestSite if the sites framework is not installed -- i.e., the sites framework is no longer required to use the syndication feed framework. This is backwards incompatible if anybody has subclassed Feed and overridden init(), because the second parameter is now expected to be an HttpRequest object instead of request.path

Fixed #4459 -- Added 'raw' argument to save method, to override any pre-save processing, and modified serializers to use a raw-save. This enables serialization of DateFields with auto_now/auto_now_add. Also modified serializers to invoke save() directly on the model baseclass, to avoid any (potentially order-dependent, data modifying) behavior in a custom save() method.

Fixed #4538 -- Split the installation instructions to differentiate between installing a distribution package and installing an official release. Thanks to Carl Karsten for the idea, and Paul Bissex for the patch.

Fixed #3505 -- Added handling for the error raised when the user forgets the comma in a single element tuple when defining AUTHENTICATION_BACKENDS. Thanks for the help identifying this problem, Mario Gonzalez <gonzalemario@…>.