On Sep 20, 2016 5:16 PM, "Netesy Emmanuel" <net...@gmail.com> wrote:
>
> My View.py
>
> class EducationCreate(CreateView):
> model = Education
> form_class = EducationForm
>
This is the linkage, so it looks like you already have it in place. Is there a specific issue you are having?
> def form_valid(self, form):
> form.instance.student = self.request.user
> return super(EducationCreate, self).form_valid(form)
>
> @method_decorator(login_required)
> def dispatch(self, *args, **kwargs):
> return super(EducationCreate, self).dispatch(*args, **kwargs)
>
Are you using 1.10? If so, you can take advantage of the new LoginRequiredMixin so that you don't need to decorate the dispatch() method.
https://docs.djangoproject.com/en/1.10/topics/auth/default/#the-loginrequired-mixin
-James