Admin¶
ExportJobAdmin
¶
Bases: BaseImportExportJobAdminMixin, ModelAdmin
Admin class for debugging ExportJob.
Source code in import_export_extensions/admin/model_admins/export_job_admin.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
cancel_jobs(request, queryset)
¶
Admin action for cancelling data export.
Source code in import_export_extensions/admin/model_admins/export_job_admin.py
192 193 194 195 196 197 198 199 200 201 202 203 204 | |
export_job_progress_view(request, job_id, **kwargs)
¶
View to return ExportJob status as JSON.
If current status is exporting, view also returns job state and percent of completed work.
Return
Response: dictionary with status (optionally, state and percent).
Source code in import_export_extensions/admin/model_admins/export_job_admin.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
get_fieldsets(request, obj)
¶
Get fieldsets depending on object status.
Source code in import_export_extensions/admin/model_admins/export_job_admin.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
get_urls()
¶
Add url to get current export job progress in JSON representation.
/admin/import_export_extensions/exportjob/
Source code in import_export_extensions/admin/model_admins/export_job_admin.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
ImportJobAdmin
¶
Bases: BaseImportExportJobAdminMixin, ModelAdmin
Admin class for debugging ImportJob.
Source code in import_export_extensions/admin/model_admins/import_job_admin.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
cancel_jobs(request, queryset)
¶
Admin action for cancelling data import.
Source code in import_export_extensions/admin/model_admins/import_job_admin.py
251 252 253 254 255 256 257 258 259 260 261 262 263 | |
confirm_jobs(request, queryset)
¶
Admin action for confirming data import.
Source code in import_export_extensions/admin/model_admins/import_job_admin.py
265 266 267 268 269 270 271 272 273 274 275 276 277 | |
get_fieldsets(request, obj)
¶
Get fieldsets depending on object status.
Source code in import_export_extensions/admin/model_admins/import_job_admin.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
get_queryset(request)
¶
Override get_queryset.
Do not get result from db because it can be rather big and is not
used in admin.
Source code in import_export_extensions/admin/model_admins/import_job_admin.py
67 68 69 70 71 72 73 74 | |
get_urls()
¶
Add url to get current import job progress in JSON representation.
/admin/import_export_extensions/importjob/
Source code in import_export_extensions/admin/model_admins/import_job_admin.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
import_job_progress_view(request, job_id, **kwargs)
¶
View to return ImportJob status as JSON.
If current status is parsing/importing, view also returns job state and percent of completed work.
Return
Response: dictionary with status (optionally, state and percent).
Source code in import_export_extensions/admin/model_admins/import_job_admin.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
BaseImportExportJobAdminMixin
¶
Mixin provides common methods for ImportJob and ExportJob admins.
Source code in import_export_extensions/admin/model_admins/mixins.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
get_from_content_type(obj)
¶
Shortcut to get object from content_type.
Source code in import_export_extensions/admin/model_admins/mixins.py
46 47 48 49 50 51 52 53 54 55 56 57 | |
has_add_permission(request, *args, **kwargs)
¶
Import/Export Jobs should not be created using this interface.
Source code in import_export_extensions/admin/model_admins/mixins.py
12 13 14 15 16 17 18 19 | |
has_delete_permission(request, *args, **kwargs)
¶
Import/Export Jobs should not be deleted using this interface.
Instead, admins must cancel jobs.
Source code in import_export_extensions/admin/model_admins/mixins.py
21 22 23 24 25 26 27 28 29 30 31 32 | |
ExportJobAdminForm
¶
Bases: ModelForm
Admin form for ExportJob model.
Adds custom export_progressbar field that displays current export
progress using AJAX requests to specified endpoint. Fields widget is
defined in __init__ method.
Source code in import_export_extensions/admin/forms/export_job_admin_form.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
__init__(instance, *args, **kwargs)
¶
Provide export_progressbar widget the ExportJob instance.
Source code in import_export_extensions/admin/forms/export_job_admin_form.py
22 23 24 25 26 27 28 29 30 31 32 33 34 | |
ImportJobAdminForm
¶
Bases: ModelForm
Admin form for ImportJob model.
Adds custom import_progressbar field that displays current import
progress using AJAX requests to specified endpoint. Fields widget is
defined in __init__ method.
Source code in import_export_extensions/admin/forms/import_job_admin_form.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
__init__(instance, *args, **kwargs)
¶
Provide import_progressbar widget the ImportJob instance.
Source code in import_export_extensions/admin/forms/import_job_admin_form.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
ForceImportForm
¶
Bases: ImportForm
Import form with force_import option.
Source code in import_export_extensions/admin/forms/import_admin_form.py
6 7 8 9 10 11 12 | |
ModelInfo
dataclass
¶
Contain base info about imported model.
Source code in import_export_extensions/admin/mixins/types.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
CeleryExportAdminMixin
¶
Bases: BaseExportMixin, BaseCeleryImportExportAdminMixin
Admin mixin for celery export.
Admin export work-flow is
GET celery_export_action() - display form with format type input
POST celery_export_action() - create ExportJob and starts data export
This view redirects to next view:
GET celery_export_job_status_view() - display ExportJob status (with
progress bar). When data exporting is done, redirect to next view:
GET celery_export_job_results_view() - display export results. If no
errors - success message and link to the file with exported data.
If errors - traceback and error message.
Source code in import_export_extensions/admin/mixins/export_mixin.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
celery_export_action(request, *args, **kwargs)
¶
Show and handle export.
GET: show export form with format_type input POST: create ExportJob instance and redirect to it's status
Source code in import_export_extensions/admin/mixins/export_mixin.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
changelist_view(request, context=None)
¶
Add the check for permission to changelist template context.
Source code in import_export_extensions/admin/mixins/export_mixin.py
348 349 350 351 352 353 354 355 356 | |
create_export_job(request, resource_class, resource_kwargs, file_format)
¶
Create and return instance of export job with chosen format.
Source code in import_export_extensions/admin/mixins/export_mixin.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
export_job_results_view(request, job_id, *args, **kwargs)
¶
Display export results.
GET-request
- show message
- if no errors - show file link
- if errors - show traceback and error
Source code in import_export_extensions/admin/mixins/export_mixin.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
export_job_status_view(request, job_id, **kwargs)
¶
View to track export job status.
Displays current export job status and progress (using JS + another view).
If job result is ready - redirects to another page to see results.
Source code in import_export_extensions/admin/mixins/export_mixin.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
get_export_context_data(**kwargs)
¶
Get context data for export.
Source code in import_export_extensions/admin/mixins/export_mixin.py
76 77 78 | |
get_export_job(request, job_id)
¶
Get ExportJob instance.
Raises Http404
Source code in import_export_extensions/admin/mixins/export_mixin.py
290 291 292 293 294 295 296 297 298 299 300 301 | |
get_resource_kwargs(request, *args, **kwargs)
¶
Return filter kwargs for resource queryset.
Source code in import_export_extensions/admin/mixins/export_mixin.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
get_urls()
¶
Return list of urls.
/<model/celery-export/:
ExportForm ('export_action' method)
/
Source code in import_export_extensions/admin/mixins/export_mixin.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
CeleryImportExportMixin
¶
Bases: CeleryImportAdminMixin, CeleryExportAdminMixin
Import and export mixin.
Source code in import_export_extensions/admin/mixins/import_export_mixin.py
5 6 7 8 9 10 11 12 13 14 | |
CeleryImportAdminMixin
¶
Bases: BaseImportMixin, BaseCeleryImportExportAdminMixin
Admin mixin for celery import.
Admin import work-flow is:
GET celery_import_action() - display form with import file input
POST celery_import_action() - save file and create ImportJob.
This view redirects to next view:
GET celery_import_job_status_view() - display ImportJob status (with
progress bar and critical errors occurred). When data parsing is
done, redirect to next view:
GET celery_import_job_results_view() - display rows that will be
imported and data parse errors. If no errors - next step.
If errors - display same form as in import_action()
POST celery_import_job_results_view() - start data importing and
redirect back to GET celery_import_job_status_view()
with progress bar and import totals.
Source code in import_export_extensions/admin/mixins/import_mixin.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
celery_import_action(request, *args, **kwargs)
¶
Show and handle ImportForm.
GET
show import form with data_file input form
POST: create ImportJob instance and redirect to it's status
Source code in import_export_extensions/admin/mixins/import_mixin.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
celery_import_job_results_view(request, job_id, *args, **kwargs)
¶
Display table with import results and import confirm form.
GET-request
- show row results
- if data valid - show import confirmation form
- if data invalid - show ImportForm for uploading other file
POST-request
- start data importing if data is correct
Source code in import_export_extensions/admin/mixins/import_mixin.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
celery_import_job_status_view(request, job_id, **kwargs)
¶
View to track import job status.
Displays current import job status and progress (using JS + another view).
If job result is ready - redirects to another page to see results.
Also generates admin log entries if the job has IMPORTED status.
Source code in import_export_extensions/admin/mixins/import_mixin.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
changelist_view(request, context=None)
¶
Add the check for permission to changelist template context.
Source code in import_export_extensions/admin/mixins/import_mixin.py
405 406 407 408 409 410 411 412 413 | |
create_import_job(request, form, resource)
¶
Create and return instance of import job.
Source code in import_export_extensions/admin/mixins/import_mixin.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
get_import_context_data(**kwargs)
¶
Get context data for import.
Source code in import_export_extensions/admin/mixins/import_mixin.py
101 102 103 | |
get_import_job(request, job_id)
¶
Get ImportJob instance.
Raises Http404
Source code in import_export_extensions/admin/mixins/import_mixin.py
340 341 342 343 344 345 346 347 348 349 350 351 | |
get_urls()
¶
Return list of urls.
- /
/ /: ImportForm ('celery_import_action' method) - /
/ / /: status of ImportJob and progress bar ('celery_import_job_status_view') - /
/ / /results/: table with import results (errors) and import confirmation ('celery_import_job_results_view')
Source code in import_export_extensions/admin/mixins/import_mixin.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
ProgressBarWidget
¶
Bases: Widget
Widget for progress bar field.
Value for progress_bar element is changed using JS code.
Source code in import_export_extensions/admin/widgets.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
Media
¶
Class with custom assets for widget.
Source code in import_export_extensions/admin/widgets.py
36 37 38 39 40 41 42 43 44 45 | |
__init__(*args, **kwargs)
¶
Get ImportJob or ExportJob instance from kwargs.
ImportJob or ExportJob instance is used
to render hidden element in render method.
Source code in import_export_extensions/admin/widgets.py
15 16 17 18 19 20 21 22 23 24 | |
render(*args, **kwargs)
¶
Render HTML5 progress element.
Additionally, method provides hidden import_job_url and
export_job_url value that is used in js/admin/progress_bar.js
to send GET requests.
Source code in import_export_extensions/admin/widgets.py
26 27 28 29 30 31 32 33 34 | |