Admin site : hide a ForeignKey field
|Reported by:||Owned by:||Adrian Holovaty|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
If you have a model with a ForeignKey that should not be editable by the user, you can try to do :
author = models.ForeignKey(User, editable=False)
But you will get "Key 'author' not found in Form" on /admin/blog/model/add/.
You can also specify the fields to display with the var "fields" of the Admin model and remove the author, but you will get "Key 'c' not found in Form" ('c' may vary).
So there is no way to hide this field (that I would like to assign without user's intervention in the method save_add).