Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a2429df
feat: static 설정 / 아이콘 추가 / css 적용
Pueropstar May 15, 2023
1290d65
design: ui 디자인 / mixin 단게로 구분
Pueropstar May 15, 2023
76a37b4
feat: media 파일 설정
Pueropstar May 15, 2023
4b66f04
feat: create 실습
Pueropstar May 15, 2023
4ae9408
chore : date 필드 명 변경 -> create_at
Pueropstar May 15, 2023
387edf4
feat: Read 실습
Pueropstar May 15, 2023
55a3ec2
feat: django tool bar 세팅
Pueropstar May 15, 2023
cfb7c2a
chore: migration / 데이터 추가
Pueropstar May 16, 2023
d6d25c5
feat: detail 페이지 read 실습
Pueropstar May 16, 2023
465de09
feat: update 실습
Pueropstar May 16, 2023
79ff682
feat: delete 실습 / template 이름 변경
Pueropstar May 16, 2023
73f8f3a
First Commit
Pueropstar May 20, 2023
8295786
Revert "First Commit"
Pueropstar May 20, 2023
7308d49
First Commit
Pueropstar May 20, 2023
12e4285
chore: 언어설정 한국어로 변경
Pueropstar May 20, 2023
9f0f403
feat: Read 구현 / 홈 화면 디자인
Pueropstar May 20, 2023
3fd06fe
feat: modal 창을 위한 함수 추가
Pueropstar May 21, 2023
8a11689
feat: CRUD 구현
Pueropstar May 21, 2023
242cac7
refactor: 주석제거
Pueropstar May 21, 2023
1b1581f
chore: Test 이름 변경
Pueropstar May 21, 2023
90e3655
chore: db 업데이트
Pueropstar May 21, 2023
69e1c38
django model form/유효성 검사 실습
Pueropstar May 22, 2023
6ea4b30
회원가입 / 로그인 실습
Pueropstar May 25, 2023
80cd71b
회원가입 제작중
Pueropstar May 25, 2023
bc414e4
회원가입 폼 디자인
Pueropstar May 25, 2023
1180b7e
로그아웃 구현
Pueropstar May 26, 2023
3d1c0d1
회원가입 / 로그인 / 로그아웃 구현
Pueropstar May 26, 2023
2ecda3d
DRF FBV CBV 실습
Pueropstar May 29, 2023
625249f
Merge branch 'main' of https://github.com/Pueropstar/Back-end
Pueropstar May 29, 2023
c98a2e5
제네릭 뷰를 사용한 CRUD 실습
Pueropstar May 29, 2023
6be90e7
ViewSets 실습
Pueropstar May 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added liongram-api/config/__init__.py
Empty file.
Binary file not shown.
Binary file not shown.
Binary file added liongram-api/config/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file added liongram-api/config/__pycache__/wsgi.cpython-39.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions liongram-api/config/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for config project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")

application = get_asgi_application()
125 changes: 125 additions & 0 deletions liongram-api/config/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
"""
Django settings for config project.

Generated by 'django-admin startproject' using Django 4.2.1.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-zuj*hqjt2dcxu*nm56_a(&%5a=y+o*i^#hd*y)mt2w@@vy95y&"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"posts",
]

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = "config.urls"

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = "config.wsgi.application"


# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}


# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/

LANGUAGE_CODE = "en-us"

TIME_ZONE = "UTC"

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_URL = "static/"

# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
19 changes: 19 additions & 0 deletions liongram-api/config/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

from django.contrib import admin
from django.urls import path, include
from rest_framework import routers
from posts.views import PostListCreateView, PostRetrieveUpdateView, PostModelViewSet, calculator,CalculatorAPIView

router = routers.DefaultRouter()
router.register('posts',PostModelViewSet)
# router.register('comments ',CommentHyperlinkedModelSerializer)

urlpatterns = [
path("", include(router.urls)),
# path('posts/',PostListCreateView.as_view(),name='post-list-create'),
# path('posts/<int:pk>',PostRetrieveUpdateView.as_view(), name='post-detail'),
path("admin/", admin.site.urls),
# path('calculator/',calculator, name="calculator-fbv"),
path('calculator/',CalculatorAPIView.as_view(), name="calculator-cbv"),

]
16 changes: 16 additions & 0 deletions liongram-api/config/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for config project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")

application = get_wsgi_application()
Binary file added liongram-api/db.sqlite3
Binary file not shown.
Binary file added liongram-api/logoBG-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added liongram-api/logoBG-3_EuPTKsK.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions liongram-api/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == "__main__":
main()
Empty file added liongram-api/posts/__init__.py
Empty file.
Binary file not shown.
Binary file added liongram-api/posts/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file added liongram-api/posts/__pycache__/apps.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions liongram-api/posts/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.contrib import admin
from .models import Post, Comment
# Register your models here.
@admin.register(Post)

class PostModelAdmin(admin.ModelAdmin):
pass

@admin.register(Comment)
class CommentModelAdmin(admin.ModelAdmin):
pass
6 changes: 6 additions & 0 deletions liongram-api/posts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class PostsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "posts"
84 changes: 84 additions & 0 deletions liongram-api/posts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Generated by Django 4.2.1 on 2023-05-29 09:57

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name="Post",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"image",
models.ImageField(
blank=True, null=True, upload_to="", verbose_name="이미지"
),
),
("content", models.TextField(verbose_name="내용")),
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="작성일"),
),
("view_Count", models.IntegerField(default=0, verbose_name="조회수")),
(
"writer",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
),
migrations.CreateModel(
name="Comment",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("content", models.TextField(verbose_name="내용")),
(
"created_at",
models.DateTimeField(auto_now_add=True, verbose_name="작성일"),
),
(
"post",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="posts.post"
),
),
(
"writer",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
),
]
Empty file.
Binary file not shown.
Binary file not shown.
20 changes: 20 additions & 0 deletions liongram-api/posts/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.db import models
from django.contrib.auth import get_user_model

User = get_user_model()

# Create your models here.

class Post(models.Model):
image = models.ImageField(verbose_name='이미지', null = True, blank = True ) # 사용자나 관리자나 field에 대한 이름을 지정
content = models.TextField(verbose_name='내용')
created_at = models.DateTimeField(verbose_name='작성일', auto_now_add=True)
view_Count = models.IntegerField(verbose_name='조회수', default = 0)
writer = models.ForeignKey(to=User, on_delete=models.CASCADE, null = True, blank = True)


class Comment(models.Model):
content = models.TextField(verbose_name='내용')
created_at = models.DateTimeField(verbose_name='작성일',auto_now_add=True)
post = models.ForeignKey(to='Post', on_delete=models.CASCADE)
writer = models.ForeignKey(to=User, on_delete=models.CASCADE)
40 changes: 40 additions & 0 deletions liongram-api/posts/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from rest_framework.serializers import ModelSerializer, HyperlinkedModelSerializer
from .models import Post,Comment

class PostBaseModelSerializer(ModelSerializer):
class Meta:
model = Post
fields= '__all__'


class PostListModelSerializer(PostBaseModelSerializer):

class Meta(PostBaseModelSerializer.Meta):
fields = ['id',
'image',
'created_at',
'view_Count',
'writer',
]
depth=1
class PostRetrieveModelSerializer(PostBaseModelSerializer):

class Meta(PostBaseModelSerializer.Meta):
depth=1

class PostCreateModelSerializer(PostBaseModelSerializer):
class Meta(PostBaseModelSerializer.Meta):
fields=[
'image',
'content',
]


class PostDeleteModelSerializer(PostBaseModelSerializer):

pass

class CommentListModelSerializer(ModelSerializer):
class Meta:
model = Comment
fields = '__all__'
3 changes: 3 additions & 0 deletions liongram-api/posts/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
Loading