[portland] django helper
freyley at gmail.com
Wed Apr 8 20:38:21 CEST 2009
On Wed, Apr 8, 2009 at 11:08 AM, Patrick Curtain <pcurtain at gmail.com> wrote:
> 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:
exclude = ('member',)
def save_model(self, request, obj, form, change):
obj.member = request.user
But looking at the doc, save_formset might do what you want:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Portland