This is a common question for Django. The challenge here is that request.user is known to the view, but not to the model... so you can't just make request.user the default value on the model.<br><br>Take a look at this and browse down to "The Holy Grail":<br>
<a href="http://www.b-list.org/weblog/2006/nov/02/django-tips-auto-populated-fields/">http://www.b-list.org/weblog/2006/nov/02/django-tips-auto-populated-fields/</a><br><br>HTH,<br><br>Dylan<br><blockquote style="margin: 1.5em 0pt;">
</blockquote><br><br><div class="gmail_quote">On Wed, Apr 8, 2009 at 11:08 AM, Patrick Curtain <span dir="ltr"><<a href="mailto:pcurtain@gmail.com">pcurtain@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hey!<br>
<div class="im"><br>
> There's a few of us here who work on Django. If you have specific<br>
> questions, you could probably get several responses. Some might even be<br>
> helpful. :-)<br>
<br>
</div>I'll start here then, for now. :) Thanks! Anyone else, feel free to<br>
tell me it's too specific for the pdxpython list.<br>
<br>
I've got a 'Recipe' model that needs to store the author. From what I<br>
could learn in other examples, this got added to my model:<br>
<br>
member = models.ForeignKey(User, related_name="added_recipes",<br>
blank=True, null=True)<br>
<br>
When I view the form in the admin interface, it works, but that field<br>
shows up as a select box of all users in the system.<br>
<br>
My goal is to let some bulk data entry happen in advance of the full<br>
app being completed. Hence the push to make it work in admin and get<br>
going.<br>
<br>
Question:<br>
<br>
How do I tell the admin interface form (via the internal 'class Admin'<br>
magic ideally) that it should get the user from the 'request.user'<br>
currently using the app?<br>
<br>
Responses of "dumb idea, do this instead" -just- as welcome. :)<br>
<br>
And thanks, everyone!<br>
<font color="#888888">--p<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Portland mailing list<br>
<a href="mailto:Portland@python.org">Portland@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/portland" target="_blank">http://mail.python.org/mailman/listinfo/portland</a><br>
</div></div></blockquote></div><br>