File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -307,15 +307,11 @@ def get_resource_type_from_serializer(serializer):
307
307
def get_resource_id (resource_instance , resource ):
308
308
"""Returns the resource identifier for a given instance (`id` takes priority over `pk`)."""
309
309
if resource and "id" in resource :
310
- return (
311
- encoding .force_str (resource ["id" ]) if resource ["id" ] is not None else None
312
- )
310
+ _id = resource ["id" ]
311
+ return encoding .force_str (_id ) if _id is not None else None
313
312
if resource_instance :
314
- return (
315
- encoding .force_str (resource_instance .pk )
316
- if hasattr (resource_instance , "pk" ) and resource_instance .pk is not None
317
- else None
318
- )
313
+ pk = getattr (resource_instance , "pk" , None )
314
+ return encoding .force_str (pk ) if pk is not None else None
319
315
return None
320
316
321
317
You can’t perform that action at this time.
0 commit comments