bakerydemo icon indicating copy to clipboard operation
bakerydemo copied to clipboard

Enable `USE_THOUSANDS_SEPARATOR` by default & have some larger test ids

Open lb- opened this issue 2 years ago • 3 comments

I think it would be good for us to have a way to easily test for common issues that relate to large ID values mixed with the usage of thousands separator.

Problem

<input value={{ my_object.id }} type="checkbox" />

This code will mostly work but if the id is over 1000, it will be rendered as 1,000.

This kind of bug has happened a few times and it would be good for us to more easily see this problem in Bakerydemo.

It's more pronounced depending on language and the setting USE_THOUSAND_SEPARATOR is True.

https://docs.djangoproject.com/en/4.2/ref/settings/#std-setting-USE_THOUSAND_SEPARATOR

Proposal

  • We update the initial data to have a random set of pages, images and maybe even a user or two to have id 1001, 1002 etc.
  • We enable the USE_THOUSAND_SEPARATOR setting by default

Related

  • https://github.com/wagtail/wagtail/pull/11137 / https://github.com/wagtail/wagtail/issues/11134
  • https://github.com/wagtail/wagtail/issues/4711
  • https://github.com/wagtail/wagtail/issues/3227
  • https://github.com/wagtail/bakerydemo/issues/448

lb- avatar Oct 26 '23 21:10 lb-

My one reservation is that I'd rather not encourage greater use of USE_THOUSAND_SEPARATOR in the wild - IMO it really is a terrible design choice to apply formatting by default and require a template filter to turn it off, rather than the other way round - and if we put it in bakerydemo, people will copy it however much we advise against it. Maybe if we put a big capitalised PLEASE DON'T DO THIS comment next to it... :-)

gasman avatar Oct 26 '23 21:10 gasman

Hmm. That's a good point. Do we know if this kind of issue will appear without that setting on?

Maybe a different approach is to run our Wagtail tests differently, instead of Bakerydemo data we update the data used in unit tests to be numbers above 1000 and run one version of the CI with this setting on?

lb- avatar Oct 26 '23 23:10 lb-

@lb- Hi there! I understand the concern with the comma appearing before 3 digits due to the USE_THOUSAND_SEPARATOR setting. If you're looking for assistance in resolving this issue, I'm a beginner but eager to learn, and I'd be happy to give it a shot. Let me know if you'd like me to explore alternative solutions or make adjustments to the code. I'm here to help and keen on gaining more experience!

RashiJyotishi avatar Dec 23 '23 07:12 RashiJyotishi

This shouldn't be necessary any more, now that https://github.com/wagtail/wagtail/pull/12251 is merged.

gasman avatar Aug 29 '24 11:08 gasman

Awesome. Great work on that PR Matt.

lb- avatar Aug 29 '24 20:08 lb-