Try-Django icon indicating copy to clipboard operation
Try-Django copied to clipboard

Bug: Raw Create & Delete Class Based View

Open kirankotari opened this issue 6 years ago • 2 comments
trafficstars

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

kirankotari avatar Jul 06 '19 16:07 kirankotari

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

iplitharas avatar Apr 12 '20 17:04 iplitharas

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.

DahliMusic avatar Dec 02 '20 14:12 DahliMusic