(self, instance)
| 170 | return False |
| 171 | |
| 172 | def get_attribute(self, instance): |
| 173 | if self.use_pk_only_optimization() and self.source_attrs: |
| 174 | # Optimized case, return a mock object only containing the pk attribute. |
| 175 | with contextlib.suppress(AttributeError): |
| 176 | attribute_instance = get_attribute(instance, self.source_attrs[:-1]) |
| 177 | value = attribute_instance.serializable_value(self.source_attrs[-1]) |
| 178 | if is_simple_callable(value): |
| 179 | # Handle edge case where the relationship `source` argument |
| 180 | # points to a `get_relationship()` method on the model. |
| 181 | value = value() |
| 182 | |
| 183 | # Handle edge case where relationship `source` argument points |
| 184 | # to an instance instead of a pk (e.g., a `@property`). |
| 185 | value = getattr(value, 'pk', value) |
| 186 | |
| 187 | return PKOnlyObject(pk=value) |
| 188 | # Standard case, return the object instance. |
| 189 | return super().get_attribute(instance) |
| 190 | |
| 191 | def get_choices(self, cutoff=None): |
| 192 | queryset = self.get_queryset() |
nothing calls this directly
no test coverage detected