#27986: Change BaseModelForm dictionary variable object_data to be OrderedDict
-------------------------------------+-------------------------------------
Reporter: Edvinas Jurevicius | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Forms | Version: 1.10
Severity: Normal | Resolution:
Keywords: BaseModelForm, | Triage Stage:
object_data, OrderedDict | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Edvinas Jurevicius):
Probably it's not worth adding if this going to effect the overall
perfomance, but let me give you a quick example:
I have this code below where I loop through CSV file and building the
initial data for the FormSets:
{{{
for row in csv_file:
# Zip values from csv row to defined fields in
csv_inline
zipped_data = OrderedDict(zip(self.csv_import_fields,
row))
initial_data.append(zipped_data)
ModelFormSet = modelformset_factory(self.model, ModelForm,
extra=len(initial_data))
formset = ModelFormSet(initial=initial_data)
}}}
In the view, I loop through FormSets initial data to display in the table
as the read-only data but this data doesn't match the defined table
headers for example my table headers are ID, Category but initial gives me
first Category and then ID.
{{{
{% for form in formset %}
<tr>
{% for value in form.initial.values %}
<td>{{ value }}</td>
{% endfor %}
</tr>
<tr>
<td class="hidden">
{{ form.as_p }}
</td>
</tr>
{% endfor %}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27986#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/063.949025ebd5ed4fb56228330b575bbaea%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.