Error in Django 2 1 5 Method Not Allowed

0 votes

I want to use the class UpdateView from the Class-Based View , after I finish the update and submit the form I get the error HTTP 405 Method not allowed below the Update inherit class

class  ArticleUpdateView(UpdateView):
 template_name = "articles/article_create.html"
 form_class = ArticleModelForm
 queryset = Article.objects.all()
 success_url = "/"

 def get_object(self):
  id_ = self.kwargs.get("id")
  return get_object_or_404(Article , id=id_)

 def form_valid(self,form):
  print(form.cleaned_data)
  return super().form_valid(form)
Nov 12, 2020 in Python by anonymous
• 8,880 points
699 views

1 answer to this question.

0 votes

UpdateView only allows GET and POST... if you try to do a PUT or PATCH you'll get that Method not allowed exception.

so check the method you're using on your HTML form

answered Nov 12, 2020 by Gitika
• 65,870 points

Related Questions In Python

+3 votes
2 answers

how to print array integer without [] bracket in python like result = 1,2,3,4,5

Hey @abhijmr.143, you can print array integers ...READ MORE

answered Aug 4, 2018 in Python by Omkar
• 69,090 points

edited Aug 8, 2018 by Omkar 5,328 views
0 votes
1 answer

Raw_input method is not working in python3. How to use it?

raw_input is not supported anymore in python3. ...READ MORE

answered May 4, 2018 in Python by aayushi
• 750 points
1,524 views
0 votes
1 answer

Need help installing easy_install in Python 2.7.1 on Windows 7

That tool is part of the setuptools ...READ MORE

answered Dec 26, 2018 in Python by Nymeria
• 3,520 points
274 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,847 views
0 votes
0 answers
+4 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
1,421 views
0 votes
1 answer

How to insert value by one post method in 2 table with Django?

try  import-export   library of Django or if you are ...READ MORE

answered Nov 12, 2020 in Python by Gitika
• 65,870 points
59 views
+1 vote
3 answers

(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

You are getting this error because you ...READ MORE

answered Dec 31, 2019 in Python by Kalgi
• 52,310 points
23,845 views