Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Raw Create & Delete Class Based View #3

Open
kirankotari opened this issue Jul 6, 2019 · 2 comments
Open

Bug: Raw Create & Delete Class Based View #3

kirankotari opened this issue Jul 6, 2019 · 2 comments

Comments

@kirankotari
Copy link

kirankotari commented Jul 6, 2019

In the following Raw Create Class Based View and Raw Delete Class Based View having issue on page rendering.

i.e. Creation and Deleting happening in the DB but it's not getting reflected in the course_list.html

On creation the new element is not showing,
On deleting it's still showing the deleted element in the course_list

They are working fine in the Class Views. i.e. blog

@iplitharas
Copy link

Hello,
Yes there is a small bug with the class attribute query, I have already raised the issue for the future

@DahliMusic
Copy link

DahliMusic commented Dec 2, 2020

UPDATE:
Was in fact able to resolve the method not allowed issue, but still seeing the same problem of my form not saving to the database. Solution was to add to CourseView a post method, which he has commented out in the code here and in the tutorial. I needed to tweak it a bit to get it to redirect correctly.

def post(self,request, id=1,*args, **kwargs):
context = {}
if id is not None:
obj = get_object_or_404(Course, id=id)
context['object'] = obj
return render(request,self.template_name,context)

I will keep on searching for ways to get this working better.

ORIGINAL POST:
So relieved that I am not alone. I'm having the same issue with Raw Update Class View. So far my only hint is that after trying to run the Raw Update Class my server reports:

"System check identified no issues (0 silenced).
December 02, 2020 - 05:59:10
Django version 3.1.4, using settings 'django3.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Method Not Allowed (POST): /course/2/
Method Not Allowed: /course/2/
[02/Dec/2020 05:59:13] "POST /course/2/ HTTP/1.1" 405 0
[02/Dec/2020 05:59:16] "GET /course/2/ HTTP/1.1" 200 1838"

This answer seems to indicate that means that there is a missing POST definition, but I am baffled as to where. My first impression was to maybe add some kind of POST definition to the CourseView, since that is where it redirects after save, but that was made using the base class view "Views" according to the Youtube tutorial so it should be fine as-is. I am uncertain, but I'm going to continue combing through the views and see if I can find an error on my end in comparison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants