-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[유서작성]이미지 저장 구현
- Loading branch information
Showing
14 changed files
with
73 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.0.6 on 2022-08-03 14:59 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('yuseoapp', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='yuseo', | ||
name='image', | ||
field=models.ImageField(null=True, upload_to='%Y/%m/%d'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,45 @@ | ||
from dataclasses import field | ||
from asyncio import Task | ||
from dataclasses import field, fields | ||
from rest_framework import serializers | ||
from .models import Yuseo | ||
from .models import Yuseo | ||
|
||
|
||
|
||
|
||
|
||
class YuseoSerializer(serializers.ModelSerializer): | ||
image = serializers.ImageField(use_url=True) | ||
|
||
class Meta: | ||
model = Yuseo | ||
fields = ('id', 'title', 'date', 'body') | ||
fields = ('id', 'title', 'date', 'body', 'image') | ||
|
||
class YuseoListSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Yuseo | ||
fields = ('id', 'title', 'date', 'summary') | ||
|
||
|
||
|
||
|
||
|
||
"""class TaskImageSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = TaskImage | ||
fields = ('image',) | ||
class TaskSerializer(serializers.HyperlinkedModelSerializer): | ||
user = serializers.ReadOnlyField(source='user.username') | ||
images = TaskImageSerializer(source='taskimage_set', many=True, read_only=True) | ||
class Meta: | ||
model = Task | ||
fields = ('id', 'title', 'date', 'body', 'images') | ||
def create(self, validated_data): | ||
images_data = self.context.get('view').request.FILES | ||
task = Task.objects.create(title=validated_data.get('title', 'no-title'), | ||
user_id=1) | ||
for image_data in images_data.values(): | ||
TaskImage.objects.create(task=task, image=image_data) | ||
return task""" |