Is it possible to make non-peewee models play nicely with Peewee?
I would not advise doing this, even if it works in the simple case. It will be too confusing, I think, especially if you have more than one person working on this codebase or intend to support it for a while (imagine trying to explain all this to a new hire).

Better, in my opinion, to just explicitly reference the IDs or add convenience methods. Also in your example, I don't think it is correct to `ForeignKey(User)` since `User` is not a real table. >Also in your example, I don't think it is correct to ForeignKey(User) since User is not a real table.

I don't think it'll change your response, but that was a typo, which I've since fixed.

> It will be too confusing, I think, especially if you have more than one person working on this codebase or intend to support it for a while (imagine trying to explain all this to a new hire).

This is subjective / beyond the scope of the discussion, but we optimize our codebases for folks who have been working in them for some time (which is the majority / common case). Thanks again for your consideration.
Good morning (?), @coleifer.

I'm wondering if it's possible to make non-peewee models play nicely with Peewee. Consider the following, which is contrived, but also a real pattern we use at my company:

```python
class DBUser(Model):
    pass

class DBAccount(Model):
    user = ForeignKeyField(DBUser)

class BankUser:
    """A user in our banking partner's system (not our DB)."""

class User:
    """A higher level user representing a user that lives both in our DB and in our banking partner's system."""

    def __init__(dbuser, bankuser):
        self._db = dbuser
        self._bank = bankuser
```

Is it possible, or are there officially endorsed ways, to duck-type a non-Peewee model (e.g.,`User`) so that it will play nicely with queries like the following:

```python
DBAccount.select().where(DBAccount.user == user)
```

In this particular case, adding the following methods does the trick:

```python
# We already have this method defined for other purposes.
@property
def id(self):
    return self._db.id

def __int__(self):
    return self.id
```

That's obviously brittle, though, and doesn't work when the primary key isn't the ID. I'm looking for something that doesn't rely on Peewee's internals, and wouldn't be subject to breaking from a non-major version change. I briefly looked at `Metadata`, but figured I'd ask before going further down the rabbit hole. No problem if there's nothing official or unofficial for this. Thank you.