-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
모델 생성입니다. #2
Open
kihyunnn
wants to merge
3
commits into
main
Choose a base branch
from
modelSetting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
모델 생성입니다. #2
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from django.contrib import admin | ||
|
||
from .models import * | ||
# Register your models here. | ||
admin.site.register(Assigment) #Assigment 모델 등록 | ||
admin.site.register(Submission) # Submission 모델 등록 |
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,3 +1,39 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
class Member(models.Model): # Member 모델 정의 | ||
name = models.CharField(max_length=20) # 멤버 이름 저장 | ||
|
||
class Category(models.Model): #카테고리 모델`` | ||
name = models.CharField(max_length=20,unique=True) #카테고리 이름, 중복 불가능 | ||
|
||
class Assigment(models.Model): # 과제 생성 모델 | ||
title = models.CharField(max_length=50) #제목 | ||
created_at = models.DateTimeField(auto_now_add=True) #생성일자 | ||
deadline = models.DateTimeField() #마감일자 | ||
# part로 모델을 따로 만들었다가,3개의 파트로 과제가 분류만 되면 되니 과제 모델 안에 넣어도 무방할 것 같아서 | ||
#이렇게 구현하고 view에서는 filter 메소드 통해서 구분하는 방법으로 생각해봤습니다. | ||
# 이부분은 확인하시고 피드백해주세요!! | ||
part = models.CharField(max_length=3, choices=[ | ||
('BE', 'BE'), | ||
('FE', 'FE'), | ||
('ALL', 'All') | ||
]) | ||
catagory_id = models.ForeignKey(Category, on_delete=models.CASCADE,related_name='assignments') | ||
# 카테고리:과제 = 1:N 관계 설정 | ||
content = models.TextField() #과제 내용 | ||
githubUrl = models.URLField() #github 주소 | ||
|
||
|
||
class Submission(models.Model): | ||
member_id = models.ForeignKey(Member, on_delete=models.CASCADE,related_name='assignments') | ||
# 멤버:제출물 = 1:N 관계 설정,멤버가 삭제되면 과제도 삭제 | ||
assignment_id = models.ForeignKey(Assigment, on_delete=models.CASCADE,related_name='submissions') | ||
# 과제:제출물 = 1:N 관계 설정, 과제가 삭제되면 제출물도 삭제 | ||
content = models.TextField() #제출물 내용 | ||
githubUrl = models.URLField() #github 주소 | ||
created_at = models.DateTimeField(auto_now_add=True) #생성일자(제출일자) | ||
|
||
|
||
|
||
|
||
|
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,3 +1,11 @@ | ||
from django.shortcuts import render | ||
import json | ||
from django.http import JsonResponse | ||
from .models import * | ||
from django.shortcuts import get_object_or_404 | ||
#.serializers , REST프레임워크 import 추가 필요 | ||
|
||
# Create your views here. | ||
|
||
# 고려해야 할 점 1) assgiment를 post 할 때 카테고리가 없으면 카테고리를 생성하고, 있으면 해당 카테고리에 추가해야함 | ||
# 고려해야 할 점 2) be,fe,all에 따라 파트를 구분하는 로직이 필요함 |
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,2 +1,3 @@ | ||
# drf-advanced-team4 | ||
drf실습 4팀 과제 레포입니다. | ||
|
Binary file not shown.
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,33 @@ | ||
|
||
관리자가 올리는 과제 글 -> 과제 | ||
과제 제출하는 사람이 올리는 글 -> 제출물 | ||
로 통일했습니당 | ||
|
||
- view 고려하면서 model 수정을 고려해봐야 할 점은 part 부분인 것 같아요. | ||
제 생각에는 part가 BE,FE,ALL만 존재하니 따로 모델을 안만들고, 과제 모델 안에 charfield로 만들어서 choice옵션으로 3개가 선택 가능하도록 했습니다. view에서는 filter 메소드 사용하거나 다른 방법으로 조건 처리를 하여 all일 떄, fe랑 be인 것을 다 보여주면 될 것 같아요.! <-이건 제가 하면서 생각한거라 다른 방법으로 하거나, 아예 모델의 수정이 필요하다면 수정해도 좋습니다. | ||
|
||
- 카테고리부분에서 새로운 카테고리를 만들면 새롭게 데이터가 입력되고, 기존의 카테고리면 기존의 카테고리로 분류되도록 로직이 필요합니다!(view에서) | ||
|
||
|
||
|
||
|
||
-현재 모델 기준 json 예시 | ||
|
||
1. Assigiment 모델 | ||
|
||
{ | ||
"title": "장고 모델 과제", | ||
"deadline": "2024-05-07T23:59:00", | ||
"part": "BE", | ||
"category_id": 1,<-요거를 이름으로 제공하고, 이미 있으면 그대로 사용하고, 아니면 새로 만드는 로직은 view에서 구현해야 할 것 같아요 | ||
"content": "장고 모델 기본 과제입니다. ~를 사용해서 구현해주세요", | ||
"githubUrl": "https://github.com/example/django-project" | ||
} | ||
|
||
2. Submssion 모델 | ||
{ | ||
"member_id": 2, | ||
"assignment_id": 3, | ||
"content": "장고 모델 기본 과제 제출합니다.", | ||
"githubUrl": "https://github.com/user/submission-repo" | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
카테고리랑 과제를 다대다 관계로 설정하고, 중간에 모델을 하나 더 만들어서 다대다 관계를 1:N, N:1로 푸는 방식은 어떨까요??