Я установил приложение Опросы с pip install -e git+http://[email protected]/divio/django-polls.git#egg=polls
от. Приложение сохраняется /me/env/src/polls/
. Я запускаю сервер от /me/project/
. Я получаю сообщение об ошибке. Как я могу определить, что приложение «Опросы» использует собственные модели.создать плагин из опросов aplication
Теперь я хочу создать плагин и заполнитель в моем шаблоне.
cms_plugins.py
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from polls.models import PollPlugin as PollPluginModel
from django.utils.translation import ugettext as _
class PollPlugin(CMSPluginBase):
model = PollPluginModel # <--not sure what to put here.
name = _("Poll Plugin") # Name of the plugin
render_template = "polls/plugin.html" #
def render(self, context, instance, placeholder):
context.update({'instance':instance})
return context
plugin_pool.register_plugin(PollPlugin) # register the plugin
опросы/models.py
class Poll(models.Model):
question = models.CharField(max_length=200)
def __unicode__(self): # Python 3: def __str__(self):
return self.question
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __unicode__(self): # Python 3: def __str__(self):
return self.choice_text