如何从数据库 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 中显示的名称列表?之前谢谢^^