Create a model from a set of attributes.
(self, attrs)
| 79 | raise NotImplementedError |
| 80 | |
| 81 | def prepare_model(self, attrs): |
| 82 | """ |
| 83 | Create a model from a set of attributes. |
| 84 | """ |
| 85 | if isinstance(attrs, Model): |
| 86 | attrs.client = self.client |
| 87 | attrs.collection = self |
| 88 | return attrs |
| 89 | elif isinstance(attrs, dict): |
| 90 | return self.model(attrs=attrs, client=self.client, collection=self) |
| 91 | else: |
| 92 | raise Exception(f"Can't create {self.model.__name__} from {attrs}") |