Ticket #3370: models-utf8.diff

File models-utf8.diff, 965 bytes (added by Dirk Datzert <dummy@…>, 18 years ago)

my variant patch

  • models.py

     
    88from forms import BaseForm, DeclarativeFieldsMetaclass, SortedDictFromList
    99from fields import Field, ChoiceField
    1010from widgets import Select, SelectMultiple, MultipleHiddenInput
     11from django.conf import settings
    1112
    1213__all__ = ('save_instance', 'form_for_model', 'form_for_instance', 'form_for_fields',
    1314           'ModelChoiceField', 'ModelMultipleChoiceField')
     
    3839    for f in opts.fields:
    3940        if not f.editable or isinstance(f, models.AutoField):
    4041            continue
    41         setattr(instance, f.name, clean_data[f.name])
     42        try:
     43          setattr(instance, f.name, clean_data[f.name].encode(settings.DEFAULT_CHARSET))
     44        except:
     45          setattr(instance, f.name, clean_data[f.name])
    4246    if commit:
    4347        instance.save()
    4448        for f in opts.many_to_many:
Back to Top