@@ -127,6 +127,10 @@ into the following data models:
127
127
.. note::
128
128
Except the added "slug" field, **Question** and **Choice** are copied from Django tutorial part 1.
129
129
130
+ .. note::
131
+ Please also pay attention to 'choice' sheet. There exists an arbitrary column: "Noise", which
132
+ exists to show case skipping column feature using mapdicts later.
133
+
130
134
Please visit this link http://localhost:8000/polls/import/, you shall see this upload form:
131
135
132
136
.. image:: import-page.png
@@ -168,15 +172,17 @@ The star is :meth:`~django_excel.save_book_to_database`. The parameter **models*
168
172
should be a list of django models. **initializers** is a list of initialization
169
173
functions for each model. In the example, we do not have init function for Question
170
174
so 'None' is given and `choice_func` is given to Choice. **mapdicts** is a list of
171
- column names for each model. The member of the **mapdicts** can be a dictionary
172
- as well::
175
+ column names for each model and the member of the **mapdicts** can be a dictionary::
173
176
174
177
{
175
178
"Question Text": "question_text",
176
179
"Publish Date": "pub_date",
177
180
"Unique Identifier": "slug"
178
181
}
179
182
183
+ As a dictionary, it can be used to skip columns in the incoming sheets. For example,
184
+ 'Noise' column is skipped because it was not mentioned in the mapdict.
185
+
180
186
The custom initialization function is needed when the data from the excel sheet
181
187
needs translation before data import. For example, **Choice** has a foreign
182
188
key to **Question**. When choice data are to be imported, "Question" column
0 commit comments