Skip to content

Commit

Permalink
이미저장 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyeon-github committed Aug 3, 2022
1 parent 675efb1 commit b2ba661
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 15 deletions.
2 changes: 1 addition & 1 deletion myvenv/bin/activate
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ deactivate () {
# unset irrelevant variables
deactivate nondestructive

VIRTUAL_ENV="/Users/ahyeonlim/YUSEO-Server/myvenv"
VIRTUAL_ENV="/Users/ahyeonlim/Otr-Server/myvenv"
export VIRTUAL_ENV

_OLD_VIRTUAL_PATH="$PATH"
Expand Down
2 changes: 1 addition & 1 deletion myvenv/bin/activate.csh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PA
# Unset irrelevant variables.
deactivate nondestructive

setenv VIRTUAL_ENV "/Users/ahyeonlim/YUSEO-Server/myvenv"
setenv VIRTUAL_ENV "/Users/ahyeonlim/Otr-Server/myvenv"

set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
Expand Down
2 changes: 1 addition & 1 deletion myvenv/bin/activate.fish
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ end
# Unset irrelevant variables.
deactivate nondestructive

set -gx VIRTUAL_ENV "/Users/ahyeonlim/YUSEO-Server/myvenv"
set -gx VIRTUAL_ENV "/Users/ahyeonlim/Otr-Server/myvenv"

set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
Expand Down
2 changes: 1 addition & 1 deletion myvenv/bin/django-admin
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/Users/ahyeonlim/YUSEO-Server/myvenv/bin/python3
#!/Users/ahyeonlim/Otr-Server/myvenv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
Expand Down
2 changes: 1 addition & 1 deletion myvenv/bin/pip
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/Users/ahyeonlim/YUSEO-Server/myvenv/bin/python3
#!/Users/ahyeonlim/Otr-Server/myvenv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
Expand Down
2 changes: 1 addition & 1 deletion myvenv/bin/pip3
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/Users/ahyeonlim/YUSEO-Server/myvenv/bin/python3
#!/Users/ahyeonlim/Otr-Server/myvenv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
Expand Down
2 changes: 1 addition & 1 deletion myvenv/bin/pip3.10
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/Users/ahyeonlim/YUSEO-Server/myvenv/bin/python3
#!/Users/ahyeonlim/Otr-Server/myvenv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
Expand Down
2 changes: 1 addition & 1 deletion myvenv/bin/sqlformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/Users/ahyeonlim/YUSEO-Server/myvenv/bin/python3
#!/Users/ahyeonlim/Otr-Server/myvenv/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
Expand Down
5 changes: 5 additions & 0 deletions yuseo/yuseo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
https://docs.djangoproject.com/en/4.0/ref/settings/
"""

import os
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
Expand Down Expand Up @@ -124,3 +125,7 @@
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'


MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
4 changes: 3 additions & 1 deletion yuseo/yuseo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"""
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('yuseoapp.urls'))
]
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
1 change: 1 addition & 0 deletions yuseo/yuseoapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Migration(migrations.Migration):
('title', models.CharField(max_length=100)),
('date', models.DateTimeField(auto_now_add=True)),
('body', models.TextField()),
('image', models.ImageField(upload_to="%Y/%m/%d")),
],
),
]
18 changes: 18 additions & 0 deletions yuseo/yuseoapp/migrations/0002_alter_yuseo_image.py
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'),
),
]
6 changes: 4 additions & 2 deletions yuseo/yuseoapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ class Yuseo(models.Model):
title = models.CharField(max_length=100)
date = models.DateTimeField(auto_now_add=True)
body = models.TextField()
image = models.ImageField(upload_to='%Y/%m/%d', null=True)


def __Str__(self):
return self.title

def summary(self):
return self.body [:30]


38 changes: 34 additions & 4 deletions yuseo/yuseoapp/serializers.py
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"""

0 comments on commit b2ba661

Please sign in to comment.