推荐学习书目
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
python30
V2EX  ›  Python

django 用 DeleteView 删除一个主题下面的某一个回复后。怎么让 success_url 返回当前主题页面呢? 如下。。

  •  
  •   python30 · Jan 1, 2019 · 2580 views
    This topic created in 2712 days ago, the information mentioned may be changed or developed.
    class Delete_Reply(DeleteView):
    model = Reply
    template_name = 'bbs/delete_reply.html'
    success_url = reverse_lazy('bbs:index')

    现在删了一个回复只能返回首页
    如果 reverse_lazy('bbs:bbs_detail', pk = id)
    不知道这个 pk id 怎么传进来?
    4 replies    2019-01-02 13:34:58 +08:00
    111111111111
        1
    111111111111  
       Jan 1, 2019 via Android
    python30
        2
    python30  
    OP
       Jan 1, 2019
    @111111111111
    这个 self 参数放在哪?
    qqxx520
        3
    qqxx520  
       Jan 2, 2019 via iPhone
    不要在类上,要在对象方法里获取,参考 get_success_url()
    xpresslink
        4
    xpresslink  
       Jan 2, 2019
    reverse_lazy('bbs:bbs_detail', kwargs={'pk': id} )

    这种情况建议直接在当前页用 ajax 直接 post 回复的 id 到后端删除。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1073 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 23:29 · PVG 07:29 · LAX 16:29 · JFK 19:29
    ♥ Do have faith in what you're doing.