Hi devs,

just stumbled upon a small (docs?) issue: at https://docs.djangoproject.com/en/4.1/topics/forms/modelforms/#enabling-localization-of-fields , there is an example of how to use that feature. but copy'n'pasting that, it won't work, as "fields" is stilla required attribute in the Meta class.

For someone not knowing that before this is a bit cumbersome - even me as someone who deals quite a long time with Django, I was wondering why

1. ModelForms do not translate their fields
2. the docs don't make clear that localized_fields does not *replace* the fields attr.

So I suggest to add a line to the documentation:
fields = ("birth_date",)
This fixes 2)

I, for myself, would even go further and deprecate localized_fields - as this should be the normal behaviour. ModelForm SHOULD translate model labels as default, and a not_localized_fields = [...] (better name?) could satisfy the use cases where fields should NOT be localized - which are IMHO the minor part. This would certainly break things, and I know (and appreciate) your conservative approach in Django development.

I found an old ticket: https://code.djangoproject.com/ticket/13546 Where this was discussed. But there the "localized_excluded" option was suggested additionally to "localized_fields", which overcomplicates things and dowsn't make sense. But reversing the logic completely would make more sense IMHO.

But maybe I just didn't understand why ModelForm does NOT localize fields in the first place per default. You may have a good reason for that.

Christian

--
Dr. Christian González
https://nerdocs.at

--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/dd89fee6-0b5a-0a24-5b0e-35e5e7526a20%40nerdocs.at.
  • Mod... Christian González
    • ... 'Adam Johnson' via Django developers (Contributions to Django itself)

Reply via email to