diff options
Diffstat (limited to 'app/notes/views.py')
-rw-r--r-- | app/notes/views.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/notes/views.py b/app/notes/views.py index 209d896..1b8ec1d 100644 --- a/app/notes/views.py +++ b/app/notes/views.py @@ -4,7 +4,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin from django.urls import reverse from .models import Note -from .forms import NoteCreateForm +from .forms import NoteCreateForm, NoteEditForm class NoteCreateView(LoginRequiredMixin, CreateView): @@ -26,11 +26,15 @@ class NoteCreateView(LoginRequiredMixin, CreateView): return reverse('notes:create') - class NoteUpdateView(LoginRequiredMixin, UpdateView): model = Note - fields = ['title', 'url', 'body_markdown', 'post', 'status', 'plan'] + form_class = NoteEditForm + def get_form_kwargs(self): + kwargs = super(NoteUpdateView, self).get_form_kwargs() + kwargs.update({'user': self.request.user}) + return kwargs + def get_context_data(self, **kwargs): context = super(NoteUpdateView, self).get_context_data(**kwargs) context['is_update'] = True |