for all Django users…
please, please, pretty please use raw_id_admin (django model docs).
because, when you have a model that contains a ForeignKey (and people usually have ForeignKeys), then when you use an automatic manipulator for the given model, it will load in ALL THE DATA FROM ALL THE RELATED MODELS. for example, if you have 20.000 entries in the related table, then it will load in all those 20.000 entries.
except, if you use raw_id_admin. it’s an attribute of the ForeignKey, and contrary to the documentation, it’s effect is not restricted to the admin-framework.
Joseph Heck made some speed-tests regarding this issue
Comments
The reason this is an
The reason this is an option, FYI, is that if you use raw_id_admin, you won’t get nice boxes for your FK relations; just entry fields for ids. The default behavior assumes a small database — database sizes follow power laws, too! — so you need to give Django a “hint” when you’re relating to a large table.
Hm.. looks like your blog
Hm.. looks like your blog software messed with my comment a bit; it should say “… you won’t get nice SELECT boxes …”
thanks for the comment. i
thanks for the comment.
i also thought that that was the reason. (i somehow forgot to mention it in the post).
but on the other hand, i think this flag should be mentioned in the tutorial where the ForeignKeys are introduced, because imho it’s quite common to have a ForeignKey point to a larger db table.