Awesome... I missed that new feature.<br><br>Here's the doc:<br><br><a href="http://docs.djangoproject.com/en/dev/ref/contrib/admin/#save-model-self-request-obj-form-change">http://docs.djangoproject.com/en/dev/ref/contrib/admin/#save-model-self-request-obj-form-change</a><br>
<blockquote style="margin: 1.5em 0pt;"></blockquote><br><br><div class="gmail_quote">On Wed, Apr 8, 2009 at 11:23 AM, Rami Kassab <span dir="ltr"><<a href="mailto:rami@typethink.com">rami@typethink.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;">Patrick,<br>
There's actually a very nice method you can overwrite in your ModelAdmin class for that model. It's called save_model. If I could copy and paste on this iPhone I'd get ya a link to the docs but you should be able to track it down. Essentially, that method has access to the request so you can auto select the currently logged in user by setting your foreign key to request.user.<br>
<br>
If you know that it's always going to be the currently logged in user then you can just hide the field on the form end. Simply override the save_model method and you can set whatever defaults ya want.<br>
<br>
Hope that helps :)<br>
<br>
Rami Kassab<br>
M 503.888.8605<br>
W 503.626.6231<br>
F 503.626.6233<br>
6025 SW Jean Rd.<br>
Lake Oswego, OR 97035<br>
<br>
Sent from my iPhone.<div><div></div><div class="h5"><br>
<br>
On Apr 8, 2009, at 11:08 AM, Patrick Curtain <<a href="mailto:pcurtain@gmail.com" target="_blank">pcurtain@gmail.com</a>> wrote:<br>
<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>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
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>
</blockquote>
<br>
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>
--p<br>
_______________________________________________<br>
Portland mailing list<br>
<a href="mailto:Portland@python.org" target="_blank">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>
</blockquote>
_______________________________________________<br>
Portland mailing list<br>
<a href="mailto:Portland@python.org" target="_blank">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>