V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
vvniu
V2EX  ›  Python

怎么在评论post的时候给文章作者和@的人发送消息?

  •  
  •   vvniu · 2014-02-11 17:14:34 +08:00 · 3237 次点击
    这是一个创建于 3727 天前的主题,其中的信息可能已经有所发展或是发生改变。
    用的是django.contrib.comments的评论系统做对文章的回复,django自带的user(auth)
    post的form如下:
    <form class="form-horizontal" action="{% comment_form_target %}" method="post">
    8 条回复    1970-01-01 08:00:00 +08:00
    loading
        1
    loading  
       2014-02-11 17:35:34 +08:00 via iPhone
    在你接收该post动作的函数里处理
    先根据这个评论的条目找到作者,然后给他加条通知,再正则评论内容,给所有@过的加通知

    也就是说评论提交给你时,除了将评论内容写到comment表(假设),你还有有个通知中心的表要写。
    vvniu
        2
    vvniu  
    OP
       2014-02-11 17:49:23 +08:00
    @loading
    但是找不到这函数在哪。。。。django1.6
    loading
        3
    loading  
       2014-02-11 18:26:04 +08:00
    @vvniu 我没用过django,只用flask,抱歉
    zjgood
        4
    zjgood  
       2014-02-11 18:39:00 +08:00 via Android
    @vvniu 呃,亲爱的V友,请教一个问题。你用django1.6默认的评论系统能否输入中文姓名?我这里输入中文名字,评论出来就变拼音了。。于是无奈用了多说 http://izj.pw 现在就是这个样子
    vvniu
        5
    vvniu  
    OP
       2014-02-11 21:08:39 +08:00
    @zjgood 不过我用的是python3,应该是python解决的这个问题,现在不管什么地方用中文都毫无障碍
    Archangel_SDY
        6
    Archangel_SDY  
       2014-02-12 11:13:42 +08:00
    https://docs.djangoproject.com/en/1.6/ref/contrib/comments/signals/

    接受comment保存时的signal, 不过comment模块好像已经deprecated了.
    vvniu
        7
    vvniu  
    OP
       2014-02-12 19:06:15 +08:00
    @Archangel_SDY 嗯最后就是这么做的,deprecated了但是还能用。。。

    顺带问下,@Archangel_SDY @loading 用户的消息里的链接,点击后,怎么样才能够掉用得到函数把它设为已读?(只是用普通的models自己写的消息,在模板里啊。。。)
    Archangel_SDY
        8
    Archangel_SDY  
       2014-02-12 23:46:01 +08:00
    @vvniu 点一下就访问类似/messages/<id>/markRead的Url,然后在对应的view里改model状态呗,至于是AJAX还是普通的跳转看你的需求了.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2761 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:25 · PVG 23:25 · LAX 08:25 · JFK 11:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.