I'd like to be able to customize the parameters that gets passed to the form used in all the views of the ModelAdmin. It seems that there is currently no way to do it. A very common scenario in which this could be useful is to provide a default value for an author/user field of a model. For example I have a Post model which has an "author" field, and I must provide a default value based on the current user.
I found various ways to accomplish this, but they all seem hacks to me. So imho it would be great to have an official, correct way to do this. I found one answer[1] on stackoverflow which suggests to use "get_object". But unfortunately that method does not called by the "add_view". An other method[2] is to use the "formfield_for_foreignkey" method. And finally, reading the code of contrib.admin I came up with other 3 solutions[3]. What do you think about this? What is your favorite way to solve this problem? [1]: http://stackoverflow.com/a/8487550/641317 [2]: http://kylefuller.co.uk/posts/pre-populating-data-admin-panel/ [3]: http://pastebin.com/GVC1SKeN -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/6efef15c-ad42-4933-bad9-a5bcb8755aad%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.