Opened 3 years ago

Closed 2 weeks ago

#20468 closed New feature (fixed)

Allow loaddata to exclude some apps or models

Reported by: fizista Owned by: alexmorozov
Component: Core (Management commands) Version: master
Severity: Normal Keywords:
Cc: berker.peksag@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Would propose adding this option to the command loaddata:

  -e EXCLUDE, --exclude=EXCLUDE
                        An appname or appname.ModelName to exclude (use
                        multiple --exclude to exclude multiple apps/models).

Sometimes it can be useful if you have a file with data from multiple applications / models, and we want to import only a portion of the data.

Change History (11)

comment:1 Changed 3 years ago by akaariai

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

I am going to mark this accepted. I don't feel strongly in one way or another about this issue, I just want to get this out of unreviewed triage stage.

comment:2 Changed 7 months ago by alexmorozov

  • Owner changed from nobody to alexmorozov
  • Status changed from new to assigned

Seems useful. Recently I've faced a similar problem. Will give it a try.

comment:4 Changed 7 months ago by alexmorozov

Guys, I've got a somewhat meta question: Shall I always squash my minor fixes to PR and push --force them, or shall I leave them as separate commits? Which way is the preferred one?

comment:5 Changed 7 months ago by timgraham

If it's a huge PR, incremental commits can make follow up review easier. In this case, the patch looks small enough that you could squash right away.

comment:6 Changed 7 months ago by alexmorozov

Thank you, @timgraham. I've pushed the updated (and squashed) PR. All lights are green. It'd be nice if you review the code. I'm not sure about the source argument. Looks clumsy, but I haven't thought out another way of keeping the output compatibility. Is that OK?

comment:7 Changed 5 months ago by berkerpeksag

  • Cc berker.peksag@… added
  • Patch needs improvement set

I left some review comments on GitHub.

comment:8 Changed 4 months ago by timgraham

  • Patch needs improvement unset

comment:9 Changed 4 months ago by timgraham

  • Patch needs improvement set

Left a few more comments and branch needs a rebase to merge cleanly.

comment:10 Changed 4 weeks ago by timgraham

  • Patch needs improvement unset
  • Summary changed from loaddata - during import exclude some applications to Allow loaddata to exclude some apps or models

Updated PR from Berker.

comment:11 Changed 2 weeks ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In ae2a7da8:

Fixed #20468 -- Added loaddata --exclude option.

Thanks Alex Morozov for the initial patch.

Note: See TracTickets for help on using tickets.
Back to Top