Here's an alternative way to do it.

Something like (in view):

    post.save(user = request.user)

And in your save override:

    user = kwargs.pop('user')
    self.user = user
    super(Post, self).save(*args, **kwargs)

The reason you pop off the 'user' value instead of just reading it is
that the parent object would otherwise fail due to an unexpected
keyword argument.

Of course, this now requires you to write all your code that could
ever save an instance of a Post model to pass a user, otherwise you'll
get an exception. I just mention that because you have the field
defined as required. You could either get rid of the requirement or
ensure you always pass 'user.'

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to