如何从数据库django中检索数据。我有这样的models.py:
from cms.models.pluginmodel import CMSPlugin
from django.db import models
class Category(CMSPlugin):
name = models.CharField(max_length=50)
def __unicode__(self):
return self.name
和文件cmsplugins.py一样:
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import ugettext_lazy as _
from models import Category
class CategoryPlugin(CMSPluginBase):
model = Category
name = _("Category Plugin")
render_template = "about.html"
def render(self, context, instance, placeholder):
context['instance'] = instance
return context
plugin_pool.register_plugin(CategoryPlugin)
如何检索要在html中显示的名称列表? 谢谢^^
答案 0 :(得分:0)
在Django中,你应该将工作分成3部分。
按照link @jdotjdot的评论。这就是它在Django中完成的方式。