Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'max_digits' must be great or equal to 'decimal_places' on OpenBSD #330

Open
xc3seziu opened this issue Aug 2, 2018 · 5 comments
Open

Comments

@xc3seziu
Copy link

xc3seziu commented Aug 2, 2018

Python 3.6.5
Django 1.11.15
Mezzanine 4.3.0
Cartridge 0.13.0

I've seen this issues on other platforms but haven't been able to find the issue on OpenBSD. Local (LC_ALL) is set to en_US.UTF-8 (this was listed as a possible culprit in some situations).

Here's the full error when I run './manage.py createdb':

./manage.py createdb
/var/******/env/lib/python3.6/site-packages/mezzanine/utils/conf.py:65: UserWarning: You haven't defined the ALLOWED_HOSTS settings, which Django requires. Will fall back to the domains configured as sites.
warn("You haven't defined the ALLOWED_HOSTS settings, which "
SystemCheckError: System check identified some issues:

ERRORS:
shop.CartItem.total_price: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.CartItem.unit_price: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.Category.price_max: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.Category.price_min: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.DiscountCode.discount_deduct: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.DiscountCode.discount_exact: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.DiscountCode.min_purchase: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.Order.discount_total: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.Order.item_total: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.Order.shipping_total: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.Order.tax_total: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.Order.total: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.OrderItem.total_price: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.OrderItem.unit_price: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.Product.sale_price: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.Product.unit_price: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.ProductVariation.sale_price: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.ProductVariation.unit_price: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.Sale.discount_deduct: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.
shop.Sale.discount_exact: (fields.E134) 'max_digits' must be greater or equal to 'decimal_places'.

Please advise.

@peterkmurphy
Copy link

That issue actually came up for me (on a fresh install on a brand-spanking-new Ubuntu 18.04 system). It seems to be a locale issue. Please see:

#4

Since my locale is "LANG=C.UTF-8", it seems to have triggered this problem. I got around this by doing SHOP_CURRENCY_LOCALE = 'en_US.UTF-8' in local_settings.py

Never the less, it sounds like something that should be sorted in the installation process.

@damascene
Copy link

damascene commented Nov 1, 2022

I'm getting the same issue on fresh installation on Ubuntu 20.04
Locals are set to C by default on my server:

$ locale 
LANG=C.UTF-8
LANGUAGE=
LC_CTYPE="C.UTF-8"
LC_NUMERIC=C.UTF-8
LC_TIME=C.UTF-8
LC_COLLATE="C.UTF-8"
LC_MONETARY=C.UTF-8
LC_MESSAGES="C.UTF-8"
LC_PAPER=C.UTF-8
LC_NAME=C.UTF-8
LC_ADDRESS=C.UTF-8
LC_TELEPHONE=C.UTF-8
LC_MEASUREMENT=C.UTF-8
LC_IDENTIFICATION=C.UTF-8
LC_ALL=

When I tried to generate locales and set the currency locale to en_US.UTF-8

SHOP_CURRENCY_LOCALE = 'en_US.UTF-8'

I got:

Invalid currency locale specified for SHOP_CURRENCY_LOCALE: 'en_USA.UTF-8'

Full error

$ python manage.py createdb --noinput --nodata
Traceback (most recent call last):
  File "/home/user/.local/share/virtualenvs/website-uhzATchw/lib/python3.8/site-packages/cartridge/shop/utils.py", line 99, in set_locale
    if setlocale(LC_MONETARY, currency_locale) == "C":
  File "/usr/lib/python3.8/locale.py", line 608, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)
  File "/home/user/.local/share/virtualenvs/website-uhzATchw/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/home/user/.local/share/virtualenvs/website-uhzATchw/lib/python3.8/site-packages/django/core/management/__init__.py", line 420, in execute
    django.setup()
  File "/home/user/.local/share/virtualenvs/website-uhzATchw/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/user/.local/share/virtualenvs/website-uhzATchw/lib/python3.8/site-packages/django/apps/registry.py", line 116, in populate
    app_config.import_models()
  File "/home/user/.local/share/virtualenvs/website-uhzATchw/lib/python3.8/site-packages/django/apps/config.py", line 269, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/.local/share/virtualenvs/website-uhzATchw/lib/python3.8/site-packages/cartridge/shop/models.py", line 36, in <module>
    class Priced(models.Model):
  File "/home/user/.local/share/virtualenvs/website-uhzATchw/lib/python3.8/site-packages/cartridge/shop/models.py", line 42, in Priced
    unit_price = fields.MoneyField(_("Unit price"))
  File "/home/user/.local/share/virtualenvs/website-uhzATchw/lib/python3.8/site-packages/cartridge/shop/fields.py", line 46, in __init__
    set_locale()
  File "/home/user/.local/share/virtualenvs/website-uhzATchw/lib/python3.8/site-packages/cartridge/shop/utils.py", line 109, in set_locale
    raise ImproperlyConfigured(msg % currency_locale)
django.core.exceptions.ImproperlyConfigured: Invalid currency locale specified for SHOP_CURRENCY_LOCALE: 'en_USA.UTF-8'. You'll need to set the locale for your system, or configure the SHOP_CURRENCY_LOCALE setting in your settings module.

For some reason my system had locale as

en_US.utf8

I've played with multiple django based software installation but never seen this type of error. I guess it's something that should be handled by the installation process as @peterkmurphy suggested.

@henri-hulski
Copy link
Collaborator

If you want to use a locale in Cartridge it has to be installed in the system.
Don’t know what happened here but the locale en_USA.utf8 doesn't exists. Correct is en_US.utf8.

@damascene
Copy link

I didn't want to specify any local, I mean I just want it to get Cartridge to run but the default configurations didn't work for me.

@henri-hulski
Copy link
Collaborator

As I recall locale C doesn't work for some reason. But I need to research for the exact issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants