2017-02-13 7 views
0

Django CMSプラグインを作成中です。これまでは、フォーム、モデル、プラグインファイルを作成しました。私は設定情報を保存したいが、私がそれを保存するために行くと上記のようにエラーが出る。以下は詳細です。Django CMSプラグインの開発:__init __()は予期しないキーワード引数 'instance'を持っています

cms_plugins.py

from cms.plugin_base import CMSPluginBase 
from cms.plugin_pool import plugin_pool 
from cms.models import CMSPlugin 

from src.survey.forms import SurveyForm 
from . import models 


class SurveyPluginPublisher(CMSPluginBase): 
    """Show Polls entered by Admin.""" 

    cache = False 
    form = SurveyForm 
    model = models.SurveyPluginModel # Must add to show stuff. 
    module = "Survey" 
    name = "Awesome Survey v1.0" 
    render_template = 'survey/_hello.html' 


plugin_pool.register_plugin(SurveyPluginPublisher) 

forms.py

from django import forms 
from src.survey.models import Survey 

models.py

class SurveyForm(forms.Form): 
    # all_surveys = Survey.objects.only('name') 
    # surveys = forms.ModelChoiceField(queryset=all_surveys) 
    headline = forms.CharField(max_length=255, help_text='Enter Headline') 
    description = forms.CharField(widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),help_text='Enter Description') 

models.py

class SurveyPluginModel(CMSPlugin): 
    name = models.CharField("Survey Name", max_length=255, default='Survey Name', 
          help_text='Enter Survey Name') 
    description = models.CharField("Survey Description", max_length=500, blank=True, help_text='Write Description here') 

    def __str__(self): 
     return "Returning some Survey Text" 
+0

のサブクラスでなければなりませんか? *完全なトレースバックを表示してください。 –

答えて

2

SurveyFormは、あなたがそのエラーが出るんModelForm

class SurveyForm(forms.ModelForm): 

    class Meta: 
     model = SurveyPluginModel 
+0

'django.core.exceptions.ImproperlyConfigured: 'fields'属性または 'exclude'属性のいずれかを持たないModelFormの作成は禁止されています。フォームSurveyFormは更新が必要です。 ' – Volatil3

+1

' fields = '__all __' 'それを並べ替えました。ありがとう – Volatil3

関連する問題