mathrithms / Django-Hexadecimal-Field

https://pypi.org/project/DjangoHexadecimalField/
MIT License
0 stars 3 forks source link

Error during makemigrations when no additional validators are specified #9

Open jpmeijers opened 2 years ago

jpmeijers commented 2 years ago

Line in the model: manufacturer_id = HexadecimalField(max_length='4', default='2C2D', help_text="The manufacturer ID in hex, as it appears in the mbus frame") # Ex 2C2D

Error:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "<redacted>/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "<redacted>/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 420, in execute
    django.setup()
  File "<redacted>/venv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "<redacted>/venv/lib/python3.8/site-packages/django/apps/registry.py", line 116, in populate
    app_config.import_models()
  File "<redacted>/venv/lib/python3.8/site-packages/django/apps/config.py", line 304, 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 "<redacted>/backend/models.py", line 8, in <module>
    from backend.models_meters import MeterModel, MeterModelMeasurement
  File "<redacted>/backend/models_meters.py", line 45, in <module>
    class MeterDecryptionKeys(models.Model):
  File "<redacted>/backend/models_meters.py", line 46, in MeterDecryptionKeys
    manufacturer_id = HexadecimalField(max_length='4', default='2C2D', help_text="The manufacturer ID in hex, as it appears in the mbus frame") # Ex 2C2D
  File "<redacted>/venv/lib/python3.8/site-packages/djangoHexadecimal/fields.py", line 17, in __init__
    self.validators += [HEXA_VALID]
  File "<redacted>/venv/lib/python3.8/site-packages/django/utils/functional.py", line 49, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "<redacted>/venv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 684, in validators
    return [*self.default_validators, *self._validators]
AttributeError: 'HexadecimalField' object has no attribute '_validators'
hess8 commented 11 months ago

I also get this error trying to build the django app