๋๋ django-polymorphic๊ณผ ํจ๊ป django-guardian์ ์ฌ์ฉํ๋ ๊ฒ์ ๋ํ ๋ง์ ํ ๋ก ์ ๋ณด์์ง๋ง ๋์๊ฒ๋ ๋งค์ฐ ํผ๋์ค๋ฝ์ต๋๋ค.
์ด ๊ฒฝ์ฐ๋ฅผ ์์ํด๋ณด์ญ์์ค.
class FeedPost(PolymorphicModel):
class Meta:
default_permissions = ('add', 'change', 'delete', 'view')
class ArticleFeedPost(FeedPost):
class Meta:
default_permissions = ('add', 'change', 'delete', 'view')
django-guardian 1.4.6์์ ArticleFeedPost์ ๋ํ ๊ถํ์ ์ค์ ํ ๋ ์ด๋ฌํ ๊ถํ์ FeedPost์ ์ ์ฉ๋์ง ์์ต๋๋ค.
๋ฌธ์์๋ ๋คํ์ฑ ๊ฐ์ฒด์ ๋ํ ๋ด์ฉ์ด ์์ต๋๋ค.
http://django-guardian.readthedocs.io/en/stable/configuration.html?highlight=polymorph#guardian -get-content-type
๊ทธ๋ฌ๋ get_default_content_type์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ์ค๋ช
ํ๋ ์์ ๋ ์์ต๋๋ค.
์ ์ง๋ฌธ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. (๊ทธ๋ฐ๋ฐ ์ฌ๊ธฐ์ ์ด๋ฐ ์ง๋ฌธ์ ํด์ ์ฃ์กํฉ๋๋ค. ํ์ง๋ง ๋ค๋ฅธ ๊ณณ๋ณด๋ค ์ฌ๊ธฐ์์ ๋ต์ ์ป์ ์ ์๋ ๋ ์ข์ ๊ธฐํ๊ฐ ์์ต๋๋ค):
์๋ ํ์ญ๋๊น,
์ฅ๊ณ ๋คํ์ฑ ๋ฌธ์ ์
๋๋ค. django-polymorphic
์๋ django-guardian ์ง์์ ์ํ ์ฝ๋๊ฐ ํฌํจ๋์ด ์์ผ๋ฏ๋ก ์ง์์ ๋ํ django-polymorphic ๋ฌธ์๋ฅผ ์ฐพ์ผ์ญ์์ค.
์ธ์ฌ๋ง,
CC: @benkonrath
๋ฒ์ ๊ด๋ฆฌ ๋ฌธ์ ์ ๊ด๋ จํ์ฌ ์ฃผ์๋ฅผ ๊ธฐ์ธ์ด๊ณ ์์์ ๋ฐํํ๊ฒ ๋ ๊ฒ์ ๊ธฐ์๊ฒ ์๊ฐํฉ๋๋ค. ๋ค์ ๋ฆด๋ฆฌ์ค์์๋ ์์ ๋ฉ๋๋ค. GUARDIAN_GET_CONTENT_TYPE
๋ django 1.4.6์์ ์ถ์๋์์ต๋๋ค.
@BenDevelopment ๊ธฐ๋ณธ ๋ชจ๋ธ ์ฝํ ์ธ ์ ํ์ ๊ฒ์ํ๋ ํจ์๋ ์ต๊ทผ์ django-polymorphic์ ๋ณํฉ๋์์ต๋๋ค. ๊ธฐ๋ณธ ๋ชจ๋ธ ์ฝํ ์ธ ์ ํ์ ์ฌ์ฉํ๋ฉด ๋ณดํธ์ ๊ถํ์ด ๊ธฐ๋ณธ ๋ชจ๋ธ์์ ์๋ํฉ๋๋ค. ์ต์ ๋ฒ์ ์ django-guardian๊ณผ git์์ ์ต์ ๋ฒ์ ์ django-polymorphic์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ด ์ค์ ์ ์ถ๊ฐํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค.
GUARDIAN_GET_CONTENT_TYPE = 'polymorphic.contrib.get_polymorphic_base_content_type'
django-polymorphic์ ์ต์ git ๋ฒ์ ์ ์ฌ์ฉํ์ง ์์ผ๋ ค๋ฉด get_polymorphic_base_content_type
์ฝ๋๋ฅผ ๋ณต์ฌํ์ฌ ์์ ์ ํ๋ก์ ํธ์ ๋ถ์ฌ๋ฃ์ ์๋ ์์ต๋๋ค.
๊ณต๊ฐ๋์ง ์์ ๋ฌธ์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
https://django-polymorphic.readthedocs.io/en/latest/third-party.html#django -guardian-support
@BenDevelopment ์์ , ์ค์ ์ ๋ค์๊ณผ ๊ฐ์์ผ ํฉ๋๋ค.
GUARDIAN_GET_CONTENT_TYPE = 'polymorphic.contrib.guardian.get_polymorphic_base_content_type'
๋ฌธ์์์ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด PR์ ๋คํ์ฑ์ผ๋ก ๋ง๋ค ๊ฒ์ ๋๋ค.
๊ฐ์ฌํฉ๋๋ค! ๋ชจ๋ ์ ์๋ํฉ๋๋ค ๐ ๐ฏ !