Conversation
| <Layout style={{ minHeight: '100vh' }}> | ||
| <Sider collapsible> | ||
| <div className="logo" /> | ||
| <Menu theme="dark" mode="inline" defaultSelectedKeys={['2']}> |
There was a problem hiding this comment.
defaultSelectedKeys가 하드코딩되어 있어 다른 페이지에서 새로 고침 했을 때 활성화 메뉴가 현재 페이지랑 안맞는 이슈가 있습니다.
| <Content style={{ padding: '20px 50px', marginTop: 64, flex: '1 1 auto' }}> | ||
| <Routes> | ||
| <Route path="/users" element={<UserList />} /> | ||
| <Route path="/add" element={<UserAdd />} /> |
There was a problem hiding this comment.
사용자 추가 화면으로 이동하는데 라우팅이 /users/add가 아닌 이유가 있을까요?
| <Route path="/add" element={<UserAdd />} /> | ||
| <Route path="/edit/:id" element={<UserEdit />} /> | ||
| <Route path="/" element={<div>Dashboard Section</div>} /> | ||
| <Route path="/posts" element={<div>Posts Section</div>} /> |
|
|
||
| <Layout> | ||
| <Header style={{ padding: 0, background: '#fff', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> | ||
| <div style={{ marginLeft: '20px', display: 'flex', alignItems: 'center' }}> |
There was a problem hiding this comment.
div 대신 Space나 Flex 컴포넌트를 사용하면 더 좋을 것 같습니다.
|
|
||
| //사용자 목록 가져옴 | ||
| useEffect(() => { | ||
| fetch('/api/users') |
There was a problem hiding this comment.
Jotai나 hook을 사용하여 관리하는 것이 일반적입니다.
| dataIndex: 'id', | ||
| key: 'id', | ||
| sorter: (a, b) => a.id - b.id, | ||
| sortOrder: sortedInfo.columnKey === 'id' && sortedInfo.order, |
There was a problem hiding this comment.
sortOrder가 없어도 문제 없을 것 같은데 명시하신 이유가 있을까요?
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify(updatedUser), | ||
| }); | ||
| if (!res.ok) throw new Error('Failed to update user'); |
There was a problem hiding this comment.
mock 서버에 데이터가 없어서 404 error가 발생합니다.
| } | ||
|
|
||
| .ant-layout-header { | ||
| position: fixed; |
| const onFinish = async (values) => { | ||
| try { | ||
| const updatedUser = { ...selectedUser, ...values }; | ||
| const res = await fetch(`/api/users/${id}`, { |
There was a problem hiding this comment.
await 사용보단 then(), catch()를 사용하여 처리하는 걸 권장합니다.
| execute_from_command_line(sys.argv) | ||
|
|
||
|
|
||
| if __name__ == '__main__': |
There was a problem hiding this comment.
user_management 프로젝트는 왜 만들어진 건가요?
| page_size_query_param = 'page_size' | ||
| max_page_size = 100 | ||
|
|
||
| class UserViewSet(viewsets.ModelViewSet): |
There was a problem hiding this comment.
update, destroy 함수를 직접 구현해서 사용한다면 ModelViewSet을 상속하지 않아도 될 것 같습니다.
| from django.http import HttpResponse | ||
|
|
||
| User = get_user_model() | ||
| def home_redirect(request): |
There was a problem hiding this comment.
home_redirect 함수를 구현하신 특별한 이유가 있나요?
| """ | ||
|
|
||
| import os | ||
| import logging |
| logger = logging.getLogger('users') | ||
|
|
||
| #페이지네이션 설정 | ||
| class UserPagination(PageNumberPagination): |
There was a problem hiding this comment.
pagination 클래스는 별도 모듈로 빼면 더 좋을 것 같습니다.
추후 다른 app에서 사용가능
| pagination_class = UserPagination | ||
|
|
||
| #검색 필터링 설정 | ||
| filter_backends = [filters.SearchFilter, filters.OrderingFilter] |
There was a problem hiding this comment.
settings.py에서 기본 FilterBackend 클래스를 지정하는 옵션이 있습니다. 전체 API 대상으로 적용할 때는 이러한 방식을 주로 사용합니다.
| from django.contrib.auth.models import AbstractUser | ||
|
|
||
| class CustomUser(AbstractUser): | ||
| groups = models.ManyToManyField( |
There was a problem hiding this comment.
이미 AbstractUser에 정의되어 있는 필드를 재정의 하신 이유가 있나요?
|
|
||
| logger = logging.getLogger('users') | ||
|
|
||
| class CustomExceptionMiddleware: |
There was a problem hiding this comment.
이 모듈은 user app이 아닌 프로젝트에 종속적이여서 모듈 위치가 config 하위로 가는게 좋아 보입니다.
이슈 한 줄 요약
사용자 관리 화면, API 구현
상세 작업 내용
[frontend]
필요 기능 목록
[backend]
필요 API 목록
참고사항
http://127.0.0.1:8000/api/usershttp://127.0.0.1:8000/api/users/{id}http://127.0.0.1:8000/api/users/?search=yshttp://127.0.0.1:8000/api/users/?page={pagenum}