def get_example_data_for_post(self, **kwargs): test_response = kwargs.pop('test_response', {}) cntr = len(test_response) for step in self.wizard_forms_fields: test_response[cntr] = {} for field in step['fields']: test_response[cntr][field] = '' field_dict = TEXTS.get(field, None) if field == "is_testing": continue field_type = step['fields'][field].__class__.__name__ if field_type in ['ChoiceField']: test_response[cntr][ str(cntr) + '-' + field] = step['fields'][field].choices[-1][0] test_response[cntr][field] = step['fields'][field].choices[ -1][0] elif field_type in ['ModelChoiceField']: choice = step['fields'][field].queryset.last().id test_response[cntr][str(cntr) + '-' + field] = choice test_response[cntr][field] = choice elif field_dict: help_text = example_fields.get(field_type, None) test_response[cntr][str(cntr) + '-' + field] = help_text test_response[cntr][field] = help_text else: test_response[cntr]['fields'] = field cntr += 1 return test_response
def get_example_data_for_post(self, t_response={}): cntr = len(t_response) for step in wizard_forms_fields: t_response[cntr] = {} for field in step['fields']: t_response[cntr][field] = '' field_dict = TEXTS.get(field, None) if field_dict: help_text = field_dict.get('help_text', None) if help_text: t_response[cntr][str(cntr) + '-' + field] = help_text t_response[cntr][field] = help_text else: t_response[cntr][str(cntr) + '-' + field] = field t_response[cntr][field] = field else: t_response[cntr]['fields'] = field cntr += 1 return t_response
'area', 'title', 'data', 'proposer', ) exclude = ('organization',) def get_queryset(self, *args, **kwargs): return PopularProposal.all_objects.all() fieldset = [] for key in ProposalTemporaryDataModelForm.base_fields: fieldset.append(key) for key in TEXTS.keys(): if key not in fieldset: fieldset.append(key) @admin.register(ProposalTemporaryData) class ProposalTemporaryDataAdmin(admin.ModelAdmin): list_display = ('id', 'area', 'data', 'proposer', 'status') form = ProposalTemporaryDataModelForm fieldsets = ( (None, { 'fields': fieldset, }), ) def get_queryset(self, request):