question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django `SystemCheck` fails on KeyError `CharField` with PostgreSQL

See original GitHub issue

I run into the following issue when upgrading to django3.2

django-salesforce: 4.0 and 3.2 django: 3.2.9

Reproducible with cmd:

>> ./manage.py check

Skippable with cmd:

>> ./manage.py shell_plus --skip-checks

Traceback

>> ./manage.py check

Traceback (most recent call last):
  File "src/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/virtualenv/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/virtualenv/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/virtualenv/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/virtualenv/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/virtualenv/lib/python3.8/site-packages/django/core/management/commands/check.py", line 63, in handle
    self.check(
  File "/virtualenv/lib/python3.8/site-packages/django/core/management/base.py", line 419, in check
    all_issues = checks.run_checks(
  File "/virtualenv/lib/python3.8/site-packages/django/core/checks/registry.py", line 76, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/virtualenv/lib/python3.8/site-packages/django/core/checks/model_checks.py", line 34, in check_all_models
    errors.extend(model.check(**kwargs))
  File "/virtualenv/lib/python3.8/site-packages/django/db/models/base.py", line 1271, in check
    *cls._check_fields(**kwargs),
  File "/virtualenv/lib/python3.8/site-packages/django/db/models/base.py", line 1382, in _check_fields
    errors.extend(field.check(**kwargs))
  File "/virtualenv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 2459, in check
    *super().check(**kwargs),
  File "/virtualenv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1773, in check
    *super().check(**kwargs),
  File "/virtualenv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 203, in check
    *self._check_validators(),
  File "/virtualenv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 349, in _check_validators
    for i, validator in enumerate(self.validators):
  File "/virtualenv/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/virtualenv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 1795, in validators
    min_value, max_value = connection.ops.integer_field_range(internal_type)
  File "/virtualenv/lib/python3.8/site-packages/django/db/backends/base/operations.py", line 625, in integer_field_range
    return self.integer_field_ranges[internal_type]
KeyError: 'CharField'

After some debugging, it points to:

{'self': <salesforce.models_extend.SfCharAutoField: id>, 'validators_': [], 'internal_type': 'CharField', '__class__': <class 'django.db.models.fields.IntegerField'>}

There is clearly a mismatch between internal_type and __class__ type and CharField is not a member of integer_field_ranges.

Possible solutions I can think of:

Would it be possible to alter internal_type from salesforce.models_extend.SfCharAutoField to return AutoField?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
stefanfouliscommented, Dec 7, 2021

@hynekcer regarding sponsoring, sorry for the long delay. We spoke about my employer sponsoring you a long time ago but never quite got it done. We’re now a sponsor 🥳.

0reactions
piotrpawlaczekcommented, Jan 31, 2022

@hynekcer I’ve been testing the main branch in our setup (with pip -e git+https://github.com/django-salesforce/django-salesforce@main#egg=django-salesforce) and everything works like a charm. I don’t think anything more is needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

KeyError: ('profiles', 'talk') - How do I resolve? - Stack Overflow
Trying to build an app using Django and Postgres db. I am struggling to migrate at the moment getting this error "KeyError: ('profiles', ......
Read more >
System check framework | Django documentation
The system check framework is a set of static checks for validating Django projects. It detects common problems and provides hints for how...
Read more >
django Changelog - pyup.io
Fixed a regression in Django 4.1 that caused a migration crash on PostgreSQL when adding a model with ``ExclusionConstraint`` (:ticket:`33982`).
Read more >
Read-only fields fail silently on KeyError and AttributeError
Any serializer field with read_only=True , do not raise exception on properties. I think this is not intended behavior and it's caused by...
Read more >
KeyError: 'SECRET_KEY' on Secret Manager - Google Groups
For the Django sample app, on Cloud SQL I'm using PostgreSQL. I store the secret values (Django settings) in Secret Manager, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found