Pass it as an argument the same as any other value. Magical hacks to
try to make it available otherwise are likely to land you in trouble
later on.
--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."
Same way you pass any argument to any function or method in Python:
write your function/method to accept the argument, and pass it from
the code that calls the function/method.
It's the last bit that can throw folks...many folks seem to use
very nice/helpful bits of the framework that abstract the save()
call so it's never thought-about. Wouldn't adding a parameter to
save() stymie the admin and a number of other places that call
save() without parameters?
I guess that's part of the price to pay for including user info
in a model? :-/
-tim
Well, for years now I've been telling anyone who will listen that
auto-filling a foreign key in the admin like this is generally a bad
idea; if you don't trust your site administrators to fill out the form
properly, you've got much bigger problems. Plus, newforms-admin makes
the whole thing moot, and just as 99% of post-queryset-refactor code
I've seen has ignored everything except model inheritance (arguably
one of the *less* interesting new features), I expect 99% of
post-newforms-admin code will ignore the interesting feature and
simply turn out to be "automatically fill in the user" tricks.
Meanwhile, in public-facing forms for general (i.e., not necessarily
trusted) users, it's ridiculously easy to automatically fill in a
foreign key automatically.