Awesome... I missed that new feature. Here's the doc:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#save-model-self-request-obj-form-change On Wed, Apr 8, 2009 at 11:23 AM, Rami Kassab <[email protected]> wrote: > Patrick, > 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. > > 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. > > Hope that helps :) > > Rami Kassab > M 503.888.8605 > W 503.626.6231 > F 503.626.6233 > 6025 SW Jean Rd. > Lake Oswego, OR 97035 > > Sent from my iPhone. > > > On Apr 8, 2009, at 11:08 AM, Patrick Curtain <[email protected]> wrote: > > Hey! >> >> There's a few of us here who work on Django. If you have specific >>> questions, you could probably get several responses. Some might even be >>> helpful. :-) >>> >> >> I'll start here then, for now. :) Thanks! Anyone else, feel free to >> tell me it's too specific for the pdxpython list. >> >> I've got a 'Recipe' model that needs to store the author. From what I >> could learn in other examples, this got added to my model: >> >> member = models.ForeignKey(User, related_name="added_recipes", >> blank=True, null=True) >> >> When I view the form in the admin interface, it works, but that field >> shows up as a select box of all users in the system. >> >> My goal is to let some bulk data entry happen in advance of the full >> app being completed. Hence the push to make it work in admin and get >> going. >> >> Question: >> >> How do I tell the admin interface form (via the internal 'class Admin' >> magic ideally) that it should get the user from the 'request.user' >> currently using the app? >> >> Responses of "dumb idea, do this instead" -just- as welcome. :) >> >> And thanks, everyone! >> --p >> _______________________________________________ >> Portland mailing list >> [email protected] >> http://mail.python.org/mailman/listinfo/portland >> > _______________________________________________ > Portland mailing list > [email protected] > http://mail.python.org/mailman/listinfo/portland > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/portland/attachments/20090408/4771211e/attachment.htm> _______________________________________________ Portland mailing list [email protected] http://mail.python.org/mailman/listinfo/portland
