바뀜
둘러보기로 가기
검색하러 가기
← 이전 편집
다음 편집 →
회원관리 2-1. 커스텀유저(Profile 이용)
(편집)
2021년 11월 6일 (토) 11:15 판
318 바이트 추가됨
,
2021년 11월 6일 (토) 11:15
→더 나아가기
20번째 줄:
20번째 줄:
identifier = models.CharField(max_length=20, unique=True)
identifier = models.CharField(max_length=20, unique=True)
is_active = models.BooleanField(default=True)
is_active = models.BooleanField(default=True)
+
is_staff = models.BooleanField(default=False)
is_admin = models.BooleanField(default=False)
is_admin = models.BooleanField(default=False)
profile = models.ForeignKey(Profile, on_delete=models.CASCADE, null=True, blank=True) # 연결할 프로필모델. 아래에서 정의.
profile = models.ForeignKey(Profile, on_delete=models.CASCADE, null=True, blank=True) # 연결할 프로필모델. 아래에서 정의.
30번째 줄:
31번째 줄:
def __str__(self):
def __str__(self):
return self.identifier
return self.identifier
+
+
def has_module_perms(self, app_label):
+
'''앱 라벨을 받아, 해당 앱에 접근 가능한지 파악'''
+
return True
+
def has_perm(self, perm, obj=None):
+
'''권한 소지여부를 판단하기 위한 메서드'''
+
return True
</syntaxhighlight>그리고 프로필 계정은 필요에 따라 다음과 같이 짠다. User에서 참고해야 하므로 User모델보다 위에 위치하게 해주자.<syntaxhighlight lang="python">
</syntaxhighlight>그리고 프로필 계정은 필요에 따라 다음과 같이 짠다. User에서 참고해야 하므로 User모델보다 위에 위치하게 해주자.<syntaxhighlight lang="python">
class Profile(models.Model):
class Profile(models.Model):
Sam
사무관
,
인터페이스 관리자
,
관리자
, 교사
편집
1,408
번
둘러보기 메뉴
개인 도구
로그인하지 않음
토론
기여
계정 만들기
로그인
이름공간
문서
토론
변수
보기
읽기
편집
원본 편집
역사 보기
더 보기
검색
둘러보기
대문
최근 바뀜
임의의 문서로
미디어위키 도움말
도구
특수 문서 목록
인쇄용 판