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
azure
V2EX  ›  Python

flask-admin在后台生成的菜单怎么点都显示同一个view? 是哪里出问题了?

  •  
  •   azure · 2012-10-19 16:14:07 +08:00 · 3151 次点击
    这是一个创建于 4218 天前的主题,其中的信息可能已经有所发展或是发生改变。
    from flask.ext.admin import Admin, BaseView, expose
    class ArticleView(BaseView):
    @expose('/')
    def index(self):
    return self.render('admin/index.html')

    @expose('/createarticle/')
    def test(self):
    return self.render('admin/index2.html')

    admin=Admin(app,name="test")
    admin.add_view(ArticleView(name=u"管理文章",endpoint="listarticle",category=u"文章"))
    admin.add_view(ArticleView(name=u"创建文章",endpoint="createarticle",category=u"文章"))


    后台能够正确生成出菜单,但是无论是点“管理文章”还是点"创建文章"。它都显示 index()的内容也就是渲染出 admin/index.html的内容。

    请问我是哪里出了问题?
    1 条回复    1970-01-01 08:00:00 +08:00
    azure
        1
    azure  
    OP
       2012-10-19 16:21:26 +08:00
    当我把代码修改

    {{{
    def index(self):
    url=url_for(".test")
    return self.render('admin/index.html',url=url)
    }}}

    的时候。它输出了这样的内容。 为什么会有两个createarticle?

    /admin/createarticle/createarticle/
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5670 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 07:46 · PVG 15:46 · LAX 00:46 · JFK 03:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.