bestwish
Hong's Tistory
bestwish
전체 방문자
오늘
어제
  • 분류 전체보기 (32)
    • DevOps (21)
      • Django (15)
      • TIL (2)
      • Python (2)
      • Git (0)
      • Docker (1)
      • Infra (1)
    • Algorithm (3)
      • 백준문제 (3)
      • 이론 (0)
    • CS (6)
      • Data Structure (6)

인기 글

최근 글

hELLO · Designed By 정상우.
bestwish
DevOps/Django

[Django] django-pydenticon - 디폴트 프로필

DevOps/Django

[Django] django-pydenticon - 디폴트 프로필

2023. 1. 28. 20:11

https://django-pydenticon.readthedocs.io/en/0.2/installation.html

 

Installation — Django Pydenticon 0.2 documentation

Configuring your Django installation Once Django Pydenticon has been installed, you need to perform the following steps in order to make it available inside of your Django project: Edit your project’s settings configuration file (settings.py), and update

django-pydenticon.readthedocs.io

git에서 사용하는 디폴트 이미지처럼 사용할 수 있게 해주는 라이브러리이다.

하지만 업데이트가 안되고있어서, 수정하여 사용해야한다.

 

1. 설치

pip install django-pydenticon

 

2.  적용

# settings.py
INSTALLED_APPS = [
...
'django_pydenticon',
...
]
# <project>/urls.py
from django_pydenticon.views import image as pydenticon_image
urlpatterns = [
...
path('identicon/image/<path:data>/', pydenticon_image, name='pydenticon_image'),
]

공식문서에 나온 urls.py를 사용하면 에러가 난다. 위와 같이 수정해야 에러가 안난다.

https://github.com/azaghal/django-pydenticon/blob/master/django_pydenticon/views.py

 

GitHub - azaghal/django-pydenticon: Django Pydenticon is a Django application that builds upon Pydenticon, a Python implementati

Django Pydenticon is a Django application that builds upon Pydenticon, a Python implementation for generating identicons. Django Pydenticon exposes the capabilities of Pydenticon via web interface....

github.com

git에 있는 urls.py 내용을 수정하여 views.py의 image 를 사용한다.

 

에러발생 및 해결

\venv\lib\site-packages\django_pydenticon\settings.py", line 52, in <s.py", line 52, in <module> if not isinstance(PYDENTICON_DIGEST, collections.Callable): AttributeError: module 'collections' has no attribute 'Callable'

위와 같은 에러가 발생하는데, 파이썬 3.10 이상일 때 발생한다.

파이썬 3.9까지는 collections.Callable로 지원이 되었지만, 3.10부터는 collections.abc.Callable로 바뀌었다

라이브러리가 설치된 settings.py로 가서 수정해주면 된다.

# venv/Lib/site-packages/django_pydenticon/settings.py
...
if not isinstance(PYDENTICON_DIGEST, collections.abc.Callable): # 수정
raise ImproperlyConfigured("Setting PYDENTICON_DIGEST must be a callable digest (usually from hashlib module).")

 

'DevOps > Django' 카테고리의 다른 글

[Django] F  (0) 2023.07.05
[DRF] 이미지 URL 호스트, 포트 제거  (0) 2023.01.10
[DRF] Swagger 사용하기  (0) 2023.01.09
[Django] 프로젝트 세팅 ( + React )  (0) 2022.12.16
[Django] SENDGRID를 이용한 메일 보내기.  (0) 2022.11.10
  • 1. 설치
  • 2.  적용
  • 에러발생 및 해결
'DevOps/Django' 카테고리의 다른 글
  • [Django] F
  • [DRF] 이미지 URL 호스트, 포트 제거
  • [DRF] Swagger 사용하기
  • [Django] 프로젝트 세팅 ( + React )
bestwish
bestwish

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.