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,910 points
3,880 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,910 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,210 points

edited Aug 8, 2018 by Omkar 7,663 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,090 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
932 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,060 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
3,480 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,910 points
963 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,360 points
98,896 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