fix: 📄 restrict recipes when editing posts

This commit is contained in:
m5ka 2024-03-29 21:10:44 +00:00
parent 745a2d188b
commit 4757e4bb7a

View file

@ -81,7 +81,11 @@ class EditPostview(LoginRequiredMixin, UserPassesTestMixin, FormView):
}
def get_form(self):
return self.form_class(instance=self.post_object, **self.get_form_kwargs())
form = self.form_class(instance=self.post_object, **self.get_form_kwargs())
form.fields["recipe"].queryset = Recipe.objects.filter(
created_by=self.request.user
)
return form
@cached_property
def post_object(self):