Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp
Commits
f3ac50b1
Commit
f3ac50b1
authored
6 years ago
by
Sylvain Le Bon
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: fixed @id fields
parent
4d63cf2a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
djangoldp/serializers.py
+8
-4
8 additions, 4 deletions
djangoldp/serializers.py
setup.py
+1
-1
1 addition, 1 deletion
setup.py
with
9 additions
and
5 deletions
djangoldp/serializers.py
+
8
−
4
View file @
f3ac50b1
...
@@ -13,27 +13,31 @@ class ContainerSerializer(ListSerializer):
...
@@ -13,27 +13,31 @@ class ContainerSerializer(ListSerializer):
def
data
(
self
):
def
data
(
self
):
return
ReturnDict
(
super
(
ListSerializer
,
self
).
data
,
serializer
=
self
)
return
ReturnDict
(
super
(
ListSerializer
,
self
).
data
,
serializer
=
self
)
class
JsonLd
Related
Field
(
HyperlinkedRelatedField
):
class
JsonLdField
(
HyperlinkedRelatedField
):
def
__init__
(
self
,
view_name
=
None
,
**
kwargs
):
def
__init__
(
self
,
view_name
=
None
,
**
kwargs
):
super
().
__init__
(
view_name
,
**
kwargs
)
super
().
__init__
(
view_name
,
**
kwargs
)
#get the field name associated with the url of the view
self
.
get_lookup_args
()
def
get_lookup_args
(
self
):
try
:
try
:
lookup_field
=
get_resolver
().
reverse_dict
[
self
.
view_name
][
0
][
0
][
1
][
0
]
lookup_field
=
get_resolver
().
reverse_dict
[
self
.
view_name
][
0
][
0
][
1
][
0
]
self
.
lookup_field
=
lookup_field
self
.
lookup_field
=
lookup_field
self
.
lookup_url_kwarg
=
lookup_field
self
.
lookup_url_kwarg
=
lookup_field
except
MultiValueDictKeyError
:
except
MultiValueDictKeyError
:
pass
pass
class
JsonLdRelatedField
(
JsonLdField
):
def
to_representation
(
self
,
value
):
def
to_representation
(
self
,
value
):
try
:
try
:
return
{
'
@id
'
:
super
().
to_representation
(
value
)}
return
{
'
@id
'
:
super
().
to_representation
(
value
)}
except
ImproperlyConfigured
:
except
ImproperlyConfigured
:
return
value
.
pk
return
value
.
pk
class
JsonLdIdentityField
(
JsonLd
Related
Field
):
class
JsonLdIdentityField
(
JsonLdField
):
def
__init__
(
self
,
view_name
=
None
,
**
kwargs
):
def
__init__
(
self
,
view_name
=
None
,
**
kwargs
):
kwargs
[
'
read_only
'
]
=
True
kwargs
[
'
read_only
'
]
=
True
kwargs
[
'
source
'
]
=
'
*
'
kwargs
[
'
source
'
]
=
'
*
'
super
(
JsonLdIdentityField
,
self
).
__init__
(
view_name
,
**
kwargs
)
super
().
__init__
(
view_name
,
**
kwargs
)
def
use_pk_only_optimization
(
self
):
def
use_pk_only_optimization
(
self
):
return
False
return
False
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
f3ac50b1
...
@@ -2,7 +2,7 @@ from setuptools import setup
...
@@ -2,7 +2,7 @@ from setuptools import setup
setup
(
setup
(
name
=
'
djangoldp
'
,
name
=
'
djangoldp
'
,
version
=
'
0.4a
1
'
,
version
=
'
0.4a
2
'
,
url
=
'
https://git.happy-dev.fr/happy-dev/djangoldp/
'
,
url
=
'
https://git.happy-dev.fr/happy-dev/djangoldp/
'
,
author
=
"
Startin
'
blox
"
,
author
=
"
Startin
'
blox
"
,
author_email
=
'
sylvain@happy-dev.fr
'
,
author_email
=
'
sylvain@happy-dev.fr
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment