Error

13 views
Skip to first unread message

Suresh

unread,
Jan 2, 2019, 2:03:18 AM1/2/19
to Django users
def chapter(request, course_name=None, slug=None):
    place = Chapter.objects.get(course__course_name=course_name, slug=slug)

    add_link_form = AddLinkForm(request.POST or None)
    add_txt_form = AddTxtForm(request.POST or None)
    file_upload_form = FileUploadForm(request.POST or None, request.FILES or None)

    queryset_txt_block = TextBlock.objects.filter(text_block_fk__id=place.id)
    queryset_yt_link = YTLink.objects.filter(yt_link_fk__id=place.id)
    queryset_files = FileUpload.objects.filter(file_fk__id=place.id)

    context = {
        "title": place.chapter_name,
        "course_name": course_name,
        "slug": slug,
        "add_link_form": add_link_form,
        "add_txt_form": add_txt_form,
        "queryset_yt_link": queryset_yt_link,
        "queryset_txt_block": queryset_txt_block,
        "queryset_files": queryset_files,
        "path": "Profile",
        "redirect_path": "profile",
        "file_upload_form": file_upload_form,
    }
error.png

Bob Gailer

unread,
Jan 2, 2019, 10:17:54 AM1/2/19
to Django users

What would you like us to do? Personally I won't  / can't do anything with the code you sent because I don't know what error you got nor do I know the environment in which you run that code. I sure wish my crystal ball ball was working.

If I ran that code I would get an error reporting unknown name Chapters.

So give us enough so that we could at least get started. If you got a trace back please copy and paste the entire traceback.

If you included an attachment it did not come through.

Bob Gailer

Kuber Sodari

unread,
Jan 2, 2019, 10:45:47 AM1/2/19
to Django users
Hmm, I suspect your issue is with queryset there since it says Matching Query Doesn't exist. This error always tend to say you that your django orm query is not proper, it has certain fields or style that you can not perform in the way you have written. First of all, please check if your variables values on your queryset 
place = Chapter.objects.get(course__course_name=course_name, slug=slug)
you can't make the query with None values as you have defaulted on your method def chapter(request, course_name=None, slug=None): 
Thus, my guess would be because of these variable values you are getting that error. You should have some values there instead of None or else it will always have that error.

And another thing I was wondering, why are you not using django 2.0 :D ? 
Reply all
Reply to author
Forward
0 new messages