def to_dict(self, include_readonly=True, field_names=None):
fields = self.fields(writable=not include_readonly)<EOL>if field_names is not None:<EOL><INDENT>fields = [f for f in fields if f in field_names]<EOL><DEDENT>data = self.__dict__<EOL>return {name: data[name] for name in fields}<EOL>
Returns the instance's column values as a dict.

- `include_readonly`: if false, returns only fields that can be inserted into database.
- `field_names`: an iterable of field names to return (optional)