[Answer]-Django automatically fill user detail

1👍

You can override the form_valid function.

class MyModelAdd(CreateView):
    model = MyModel
    template_name = 'mymodeladd.html'
    fields = ('id', 'purpose', 'is_visible')

    def form_valid(self, form):
        form.instance.created_by = self.request.user
        return super(MyModelAdd, self).form_valid(form)

Leave a comment