Opened 5 years ago

Closed 5 years ago

#15505 closed (invalid)

Feature request: disable localization in some model fields

Reported by: denilsonsa Owned by: nobody
Component: Uncategorized Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


In 1.2, we now have L10N, so now Integer fields automatically have the thousand separator. That's a neat addition.

Also, we have a "localize" parameter to Form fields, setting if they should be localized or not.

However... I miss such "localize" parameter at the Model itself. For me, it makes sense to set some fields as "do not localize". For instance, suppose I have a IntegerField that holds a barcode. It makes no sense to ever localize such field, so I would like to tell this to Django.

Suggestion: add "localize" parameter also to model fields.

Change History (3)

comment:1 Changed 5 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

While I can see the desire to have this in Django, I don't think it's a good idea. Localization of values, etc., is basically just an issue of how the data is presented when displayed in a form, so forms are the right place to do this. Models shouldn't know or have to know this much about how their data will be presented.

comment:2 Changed 5 years ago by denilsonsa

  • Resolution wontfix deleted
  • Status changed from closed to reopened

I disagree because I was thinking about using them in templates without Forms.

In other words, if a template receives a model instance, or a list of model instances, then it will directly render the model fields, without using any Form. After all, I believe there are many use cases where a Form is not needed (e.g. a list of objects).

I know I can just "|unlocalize", but IMHO it makes sense to tell Django to never localize some fields.

I'm reopening, if you still disagree, just close again.

comment:3 Changed 5 years ago by russellm

  • Resolution set to invalid
  • Status changed from reopened to closed

Ubernostrum is right; this is a presentation layer problem, not a data layer problem.

Note: See TracTickets for help on using tickets.
Back to Top