Vote count: 0
First of all pardon my ignorance as I am kind of new into it.
I have been able to show a Dropdown list in Settings Window that fetches data from Db. Now I want to select some value, save and on re-opening of setting modal window I wanna show selected field. So far I figured out that CMS Plugin model actually appears on setting modal window. Below are details
models.py
class Survey(models.Model):
name = models.CharField(max_length=400)
description = models.TextField()
def __unicode__(self):
return (self.name)
def questions(self):
if self.pk:
return Question.objects.filter(survey=self.pk)
else:
return None
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"
forms.py
from django import forms from src.survey.models import Survey from src.survey.models import SurveyPluginModel
class SurveyForm(forms.ModelForm):
all_surveys = Survey.objects.only('name')
surveys = forms.ModelChoiceField(queryset=all_surveys)
class Meta:
model = SurveyPluginModel
fields = '__all__'
Now if I add a model field in SurveyPluginModel
it instantly appears on screen. What I want to save surveys = forms.ModelChoiceField(queryset=all_surveys)
selected value to place where other plugin setting is stored and next time it makes it selected. What I guess instance
is not going to help, the Plugin model field should be helpful but then I am not able to make a link with form field.
Please guide.
Django CMS Plugin: How to store combo setting and retrieve on setting window load?
Aucun commentaire:
Enregistrer un commentaire