0
大家好我的模型如何獲取值有這個屬性在get_context_data
class Entry(models.Model):
TYPES_CHOICES = (
('none', 'not specified'),
('v', 'By Visit'),
('p', 'By Patient'),
)
app_config = AppHookConfigField(HealthConfig)
url = models.CharField(blank=True, default='', max_length=250)
count = models.CharField(blank=True, default='', max_length=250)
start = models.CharField(blank=True, default='', max_length=250)
status = models.CharField(choices=TYPES_CHOICES, max_length=10, default='')
在我看來,我有這樣的
class IndexView(AppConfigMixin, generic.ListView):
model = Entry
template_name = 'health/index.html'
def get_queryset(self):
qs = super(IndexView, self).get_queryset()
return qs.namespace(self.namespace)
def get_context_data (self, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
values_to_pass = context['object_list'].values('url', 'count', 'start')
context['object_list'] = values_to_pass
print values_to_pass
return context
一個通用的列表視圖如何獲得價值url
,count
和start
加入一個值並通過html文件
final= url + count + start
現在print values_to_pass
返回空列表[]
任何想法!