Skip to content

Commit ed317ab

Browse files
authored
Merge pull request #161 from arthur-verta/master
Fix: Ensure Cache Key pk is Converted to INT to Prevent Dataframe Series Null Issues
2 parents 067746c + fdfe404 commit ed317ab

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

django_pandas/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ def replace_pk(model):
4444
base_cache_key = get_base_cache_key(model)
4545

4646
def get_cache_key_from_pk(pk):
47-
return None if pk is None else base_cache_key % str(pk)
47+
if pk is None:
48+
return None
49+
else:
50+
try:
51+
return base_cache_key % str(int(pk))
52+
except:
53+
return base_cache_key % str(pk)
4854

4955
def inner(pk_series):
5056
pk_series = pk_series.astype(object).where(pk_series.notnull(), None)

0 commit comments

Comments
 (0)