Hello,

I am experimenting with the new class based views coming in 1.3 and am
having trouble figuring out when/where to put this code. I want to
populate a model's created_by field with the user of the current
request.

In the old views, I would have done something this:
obj = form.save(commit=False)
obj.created_by = request.user
obj.save()

Now I am using a generic CreateView class:
class ListCreateView(CreateView):
    model = List
    form_class = ListForm

I tried supplying an initial data dictionary by overriding
get_initial(), but this doesn't work because the `created_by` field
has editable=False so the form doesn't include it in the fields list.

Am I missing something simple? Probably :). Any help would be greatly
appreciated!

Thanks,
-Justin



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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