On vrijdag 10 augustus 2018 16:51:54 CEST zengkeat wrote: > I have a UpdateView for editing a post, but instead of making a DeleteView > for delete a post, i try to make UpdateView include a function to delete > the post. So ,i want to edit and delete a post in UpdateView. Is that > possible ? i think i missing something in my code so the code keep getting > error.
No, you're simply not conforming to the method signature. > form_valid() missing 1 required positional argument: 'pk' Your form_valid method wants an argument 'pk': > def form_valid(self, form, pk): But Django never will give you one. What you're looking for is self.kwargs['pk'] and the method for form_valid can only accept one argument, which is the form. -- Melvyn Sopacua -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to email@example.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1714845.lzVsRMqLTZ%40fritzbook. For more options, visit https://groups.google.com/d/optout.