On Wed, Apr 8, 2009 at 11:08 AM, Patrick Curtain <span dir="ltr">&lt;<a href="mailto:pcurtain@gmail.com" target="_blank">pcurtain@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><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><br><br>
</div>   member = models.ForeignKey(User, related_name=&quot;added_recipes&quot;,<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>
</blockquote><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">How do I tell the admin interface form (via the internal &#39;class Admin&#39;<br>


magic ideally) that it should get the user from the &#39;request.user&#39;<br>
currently using the app?<br>
</blockquote><div><br>Most of what I&#39;ve seen to try to do this isn&#39;t to set a default, it&#39;s to make it happen invisibly. For example, this:<br><pre><span>class</span> <span>ArticleAdmin</span><span>(</span><span>admin</span><span>.</span><span>ModelAdmin</span><span>):</span><br>

<span>    exclude</span> <span>=</span> <span>(</span><span>&#39;member&#39;</span><span>,)</span><br>    <span>def</span> <span>save_model</span><span>(</span><span>self</span><span>,</span> <span>request</span><span>,</span> <span>obj</span><span>,</span> <span>form</span><span>,</span> <span>change</span><span>):</span><br>
        <span>obj</span><span>.</span><span>member</span> <span>=</span> <span>request</span><span>.</span><span>user</span><br>        <span>obj</span><span>.</span><span>save</span><span>()</span><br>
<span></span><br></pre>But looking at the doc, save_formset might do what you want:<br><br><a href="http://docs.djangoproject.com/en/1.0//ref/contrib/admin/#ref-contrib-admin">http://docs.djangoproject.com/en/1.0//ref/contrib/admin/#ref-contrib-admin</a><br>
<br>Jeff<br></div></div><br>