Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kszkepzes-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
KSZK
DevTeam
kszkepzes
old
kszkepzes-backend
Commits
46e950f1
Commit
46e950f1
authored
5 years ago
by
Rafael László
Browse files
Options
Downloads
Patches
Plain Diff
return relative path for images
parent
e5e012e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Dev
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/images/serializers.py
+9
-1
9 additions, 1 deletion
src/images/serializers.py
src/mentors/models.py
+1
-1
1 addition, 1 deletion
src/mentors/models.py
src/mentors/serializers.py
+9
-0
9 additions, 0 deletions
src/mentors/serializers.py
with
19 additions
and
2 deletions
src/images/serializers.py
+
9
−
1
View file @
46e950f1
...
@@ -3,7 +3,15 @@ from rest_framework import serializers
...
@@ -3,7 +3,15 @@ from rest_framework import serializers
class
ImageSerializer
(
serializers
.
ModelSerializer
):
class
ImageSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
class
Meta
:
model
=
Image
model
=
Image
fields
=
(
'
image
'
,)
fields
=
(
'
image
'
,)
def
to_representation
(
self
,
instance
):
response
=
super
(
ImageSerializer
,
self
).
to_representation
(
instance
)
if
instance
.
image
:
response
[
'
image
'
]
=
instance
.
image
.
url
return
response
This diff is collapsed.
Click to expand it.
src/mentors/models.py
+
1
−
1
View file @
46e950f1
...
@@ -14,7 +14,7 @@ class Mentor(models.Model):
...
@@ -14,7 +14,7 @@ class Mentor(models.Model):
name
=
models
.
CharField
(
null
=
False
,
max_length
=
200
)
name
=
models
.
CharField
(
null
=
False
,
max_length
=
200
)
text
=
models
.
TextField
()
text
=
models
.
TextField
()
image
=
models
.
ImageField
(
image
=
models
.
ImageField
(
upload_to
=
'
mentors/images/
'
,
null
=
True
,
blank
=
True
)
upload_to
=
'
public/
mentors/images/
'
,
null
=
True
,
blank
=
True
)
email
=
models
.
EmailField
()
email
=
models
.
EmailField
()
def
__str__
(
self
):
def
__str__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
src/mentors/serializers.py
+
9
−
0
View file @
46e950f1
...
@@ -12,3 +12,12 @@ class MentorSerializer(serializers.ModelSerializer):
...
@@ -12,3 +12,12 @@ class MentorSerializer(serializers.ModelSerializer):
def
get_mentor
(
self
,
obj
):
def
get_mentor
(
self
,
obj
):
return
obj
.
mentor
.
full_name
return
obj
.
mentor
.
full_name
def
to_representation
(
self
,
instance
):
response
=
super
(
MentorSerializer
,
self
).
to_representation
(
instance
)
if
instance
.
image
:
response
[
'
image
'
]
=
instance
.
image
.
url
return
response
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