Changes between Initial Version and Version 1 of Ticket #23615, comment 4


Ignore:
Timestamp:
Oct 14, 2014, 4:23:30 AM (10 years ago)
Author:
Rigel Di Scala

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #23615, comment 4

    initial v1  
    11I can replicate the issue.
    22
    3 The problem seems to originate here: https://github.com/django/django/blob/master/django/core/management/base.py#L418
     3The exception is raised, when running my test using the Django test management command, here: https://github.com/django/django/blob/master/django/core/management/base.py#L418
    44
    55{{{
     
    99                self.check()
    1010}}}
     11
     12`bmispelon` and I found that the problem actually originates here:
     13https://github.com/django/django/blob/master/django/core/checks/model_checks.py#L14
     14
     15{{{
     16@register(Tags.models)
     17def check_all_models(app_configs=None, **kwargs):
     18    errors = [model.check(**kwargs)
     19        for model in apps.get_models()
     20        if app_configs is None or model._meta.app_config in app_configs]
     21    return list(chain(*errors))
     22}}}
     23
     24We would therefore need to check (no pun intended) that the `check` attribute on the `model` instance does not resolve to a field, before actually calling it as a method, something to the tune of:
     25{{{
     26if mdl._meta.get_field_by_name("check"):
     27    pass
     28}}}
Back to Top