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,870 points
4,048 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,770 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 5, 2018 in Python by Omkar
• 69,220 points

edited Aug 8, 2018 by Omkar 8,149 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 5, 2018 in Python by aayushi
• 750 points
3,359 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,560 points
1,199 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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+5 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,790 points
4,070 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,770 points
1,146 views
0 votes
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,350 points
100,967 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP