将现有 django 应用程序与 django-cms 集成

发布于 2024-10-19 21:31:41 字数 955 浏览 3 评论 0原文

我有一个现有的 django 应用程序,我需要与它集成 django-cms。 Django-cms将主要用于为应用程序创建帮助文档。我已将 django-cms 设置为使用现有数据库,以保持用户和身份验证一致。

理想情况下,在帮助页面中,我需要现有应用程序中的客户特定信息,并且还向文档团队提供编辑功能。

这是我编写的示例视图:

def view_help(request, company):
    try:
        c = Company.objects.get(id=company)
    except:
        return render_to_response('help.html', {'msg':'No Such company'})

    return render_to_response('help.html', {'company':c, 'data':c.data})

相应的模板 help.html:

{% load cms_tags %}
{% load custom_tags %}

<!doctype html>
<head>
  <title>{{company}}</title>
     {% plugins_media %}
</head>
<body>
    {% placeholder "main" %}

{% if msg %}
    {{msg}}

{% else %}
    Here is company specific data: <br/> 
    {{ data }}    
{% endif %}
</body>
</html>

这为我提供了我需要的公司特定信息,但没有为我提供 cms 插件。

任何帮助将不胜感激。 谢谢。

- - 编辑 - - 将已编辑的部分移至新问题

I have an existing django application, with which I need to integrate django-cms. Django-cms will be mainly used to create help documents for the application. I've setup django-cms to use my existing database, so as to keep users and auth consistent.

Ideally in a help page, I would be needing client specific information from my existing application, and also provide editing functionality to the documentation team.

Here is a sample view which I wrote:

def view_help(request, company):
    try:
        c = Company.objects.get(id=company)
    except:
        return render_to_response('help.html', {'msg':'No Such company'})

    return render_to_response('help.html', {'company':c, 'data':c.data})

Corresponding template help.html:

{% load cms_tags %}
{% load custom_tags %}

<!doctype html>
<head>
  <title>{{company}}</title>
     {% plugins_media %}
</head>
<body>
    {% placeholder "main" %}

{% if msg %}
    {{msg}}

{% else %}
    Here is company specific data: <br/> 
    {{ data }}    
{% endif %}
</body>
</html>

This gives me the company specific information I need, but doesn't give me the cms plugins.

Any help here would be much appreciated.
Thanks.

--- Edit ---
Moved the edited section to a new question

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奶气 2024-10-26 21:31:41

您需要使用 django-cms apphook

You need to attach the application's view to a cms page using a django-cms apphook.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文