If you're using FormMixin then you can also override get_form_kwargs:

def get_form_kwargs(self):
    kwargs = super(MyForm, self).get_form_kwargs()
    kwargs['creator'] = self.request.user.pk
    return kwargs

Then let FormMixin instantiate the form instance itself.

On Wed, May 13, 2015 at 10:14 AM, David <cthl...@gmail.com> wrote:
> For anyone else needing this:
>
> In form:
>
>     def __init__(self, *args, **kwargs):
>         self.creator = kwargs.pop('creator', None)
>
> In view:
>
> form = PostForm(request.POST, creator=self.request.user.pk)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b839e5db-1d25-425e-8bbb-b8a05d501e74%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxUsARyZB_GObzi1F9E%2B_yrwuTHyNeKSG%3DGWNzu4q-GJ2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to