Hi,

We are using Django 2.2 and I want to upgrade to Django 3.0. We have a
mixin (written in 2017) that add fields to forms:

class LocalizedFirstLastNameMixin(object):
    def __init__(self, *args, **kwargs):
        self.language_code = kwargs.pop('language_code', 'en')
        super().__init__(*args, **kwargs)
        for loc_field in reversed(self.get_localized_fields()):
            self.fields[loc_field] = User._meta.get_field(loc_field).formfield()
            self.fields[loc_field].required = True
            self.fields.move_to_end(loc_field, last=False)
            self.initial[loc_field] = getattr(self.instance, loc_field, '')

It works with Django versions up to 2.2. But when I upgrade to 3.0, I get
this error message:

AttributeError: 'dict' object has no attribute 'move_to_end'

This function's info:

'''Move an existing element to the end (or beginning if last==False).

And it belongs to OrderedDict.

So I guess we want these fields to be in the beginning of the form fields.

Is there a change in the implementation of the fields in forms and how do I
specify the order of fields? And if I change it, will it work in previous
versions such as Django 2.2?

Thanks,
Uri.
אורי
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABD5YeEbHc5ewqJKEFAS5XV1JfD%3DEqf8%3D_ScgjhTC5VY2NsDpw%40mail.gmail.com.

Reply via email to