[Answered ]-Get specific uuid object in view from model in django

1👍

You probably have to modify your views and urls file as follows:

urls.py:

path('course/<str:course_id>/', views.course_detail, name='course-detail')

views.py:

def course_detail(request, course_id):
    course = models.Course.objects.get(course_id=course_id)
    context = {
        'course': course,
    }
    return render(request, 'courses/info_course_view.html', context)

template file:

<div class="container">
{{ course.title }}
</div>

In fact, the main issue is that you didn’t put the course_id inside the course argument.

Leave a comment