Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
gm-serializer
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gushitong
gm-serializer
Commits
1f4f2ffb
Commit
1f4f2ffb
authored
Aug 01, 2017
by
gushitong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix: get same obj for different obj_id
parent
c5047cc2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
__init__.py
gm_serializer/__init__.py
+1
-1
descriptor.py
gm_serializer/fields/descriptor.py
+5
-1
No files found.
gm_serializer/__init__.py
View file @
1f4f2ffb
__version__
=
'0.0.
5
'
__version__
=
'0.0.
6
'
__author__
=
'gushitong@gmei.com'
gm_serializer/fields/descriptor.py
View file @
1f4f2ffb
...
...
@@ -25,13 +25,17 @@ class MagicDescriptor(object):
if
instance
is
None
:
return
self
related_obj_pk
=
getattr
(
instance
,
"
%
s_id"
%
self
.
field
.
attname
)
if
getattr
(
instance
,
self
.
lazy_name
,
False
):
return
getattr
(
instance
,
"
%
s_id"
%
self
.
field
.
attname
)
return
related_obj_pk
try
:
lazy_obj
=
getattr
(
instance
,
self
.
cache_name
)
logger
.
debug
(
"Magic Hit ObjCache:
%
s:
%
s"
%
(
self
.
field
.
attname
,
lazy_obj
[
'id'
]))
except
AttributeError
:
# update field pk_list, or you always get the same.
self
.
field
.
accessor
.
pk_list
=
[
related_obj_pk
]
lazy_obj
=
self
.
field
.
accessor
.
get_object
()
setattr
(
instance
,
self
.
cache_name
,
lazy_obj
)
return
lazy_obj
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment