[portland] django helper

Patrick Curtain pcurtain at gmail.com
Wed Apr 8 20:41:01 CEST 2009


Wow!  Everyone, thank you SOO much.  That certainly gives me plenty to
go on.  I'll hit everyone back with the solution that sticks in my
Admin case.

And good to see all the traffic and help available.  I'd been lurking
and it seemed quiet.  :)

Blessings!
--p


On Wed, Apr 8, 2009 at 11:38 AM, Jeff Schwaber <freyley at gmail.com> wrote:
> On Wed, Apr 8, 2009 at 11:08 AM, Patrick Curtain <pcurtain at gmail.com> wrote:
>
>> Hey!
>>
>>
>>    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.
>>
>
>
>> 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?
>>
>
> Most of what I've seen to try to do this isn't to set a default, it's to
> make it happen invisibly. For example, this:
>
> class ArticleAdmin(admin.ModelAdmin):
>    exclude = ('member',)
>    def save_model(self, request, obj, form, change):
>        obj.member = request.user
>        obj.save()
>
> But looking at the doc, save_formset might do what you want:
>
> http://docs.djangoproject.com/en/1.0//ref/contrib/admin/#ref-contrib-admin
>
> Jeff
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.python.org/pipermail/portland/attachments/20090408/c41c41da/attachment.htm>
> _______________________________________________
> Portland mailing list
> Portland at python.org
> http://mail.python.org/mailman/listinfo/portland
>



-- 
Patrick Curtain,  Husband & Father  ( i also write software )
http://www.patrickcurtain.com/                          360.521.9625


More information about the Portland mailing list