summaryrefslogtreecommitdiff
path: root/app/notes/forms.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2023-07-25 16:07:46 -0500
committerluxagraf <sng@luxagraf.net>2023-07-25 16:07:46 -0500
commit547b4dfe7ffcef5062046180000ff669412b208a (patch)
tree6b57834350d56308ba9dc6f73bcacd74b0f7886b /app/notes/forms.py
parentbe4b5904a575390787b349f05f3c8dd5ad4bddb2 (diff)
notes: auto add user when saving new note
Diffstat (limited to 'app/notes/forms.py')
-rw-r--r--app/notes/forms.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/notes/forms.py b/app/notes/forms.py
index 5cde108..4342b89 100644
--- a/app/notes/forms.py
+++ b/app/notes/forms.py
@@ -7,9 +7,14 @@ class NoteCreateForm(ModelForm):
def __init__(self,*args,**kwargs):
user = kwargs.pop('user')
+ self.user = user
super(NoteCreateForm,self).__init__(*args,**kwargs)
self.fields['post'].queryset = Post.objects.filter(user=user).order_by("title")
+ def save(self, commit=True):
+ self.instance.user = self.user
+ return super().save(commit=commit)
+
class Meta:
model = Note
fields = ['title', 'url', 'body_markdown', 'post']