0
내 django 프로젝트에서 사용자에게 트위터와 같은 소셜 사이트에 사용 된 "@"기능을 태그하거나 언급하는 기능을 구현하려고합니다. 예를 들어 "@ stack"을 클릭하면 스택의 프로필로 이동해야합니다.django 프로젝트에서 '@'를 사용하여 사용자에게 '@'태그를 붙이는 방법
어떻게 수행하면 좋을까요?
내 django 프로젝트에서 사용자에게 트위터와 같은 소셜 사이트에 사용 된 "@"기능을 태그하거나 언급하는 기능을 구현하려고합니다. 예를 들어 "@ stack"을 클릭하면 스택의 프로필로 이동해야합니다.django 프로젝트에서 '@'를 사용하여 사용자에게 '@'태그를 붙이는 방법
어떻게 수행하면 좋을까요?
편집 시스템에서 편집기 시스템이 올바르게 처리됩니까? 여기에 직접 언급 사용자 @[username]
에 제공 django-markdown-editor입니다 = 다른 사용자들에 의해 언급 한 사용자, 유래와 같은 뭔가를 알림 시스템을 구현해야하는 경우
@username 기능 markdown_find_mentions
, 유용에 대한 참조>.
def markdown_find_mentions(markdown_text):
"""
To find the users that mentioned
on markdown content using `BeautifulShoup`.
input : `markdown_text` or markdown content.
return : `list` of usernames.
"""
mark = markdownify(markdown_text)
soup = BeautifulSoup(mark, 'html.parser')
return list(set(
username.text[1::] for username in
soup.findAll('a', {'class': 'direct-mention-link'})
))
그리고 이것은 간단한 흐름 프로세스입니다.
발신자에게 발신자와 수신자가 있음을 의미합니다.
class Notification(TimeStampedModel):
sender = models.ForeignKey(User, related_name='sender_n')
receiver = models.ForeignKey(User, related_name='receiver_n')
content_type = models.ForeignKey(ContentType, related_name='n', on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')
read = models.BooleanField(default=False)
....