The check seems a bit convoluted to me, you should be able to get rid of the `err` variable. What about:

```python
try:
    cls._meta.get_field(field_name, many_to_many=False)
except FieldDoesNotExist:
    if field_name.endswith('_id'):
        try:
            field = cls._meta.get_field(field_name[:-3], many_to_many=False)
        except FieldDoesNotExist:
            pass
        else:
            if field.attname == field_name:
                continue
```