{% extends 'base.html'%}
{% block content %}
<div class="container">
<div class="row">
<div>
{% for movies in movie %}
<div class="col-sm-6">
<div class="card">
<div class="card-body">
<img src="{{ movies.image.url }}" class="card-img-top" alt="...">
<a href="{% url 'detail' movies.pk %}" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endblock content%}
I don’t know how to specify the path to the function, more precisely speaking the class
class MovieDetailView(DetailView):
model = Movie
template_name = 'movie_detail.html'
context_object_name = 'detail'
pk_url_kwarg = 'movie_id'
urlpatterns = [
path('index/', views.MovieListView.as_view()),
path('movie_detail/<int:pk>', views.MovieDetailView.as_view(), name='detail')
]
AttributeError: Generic detail view MovieDetailView must be called with either an object pk or a slug in the URLconf.
[21/Apr/2023 22:05:52] "GET /o/movie_detail/1 HTTP/1.1" 500 78858
{% extends ‘base.html’%}
{% block content %}
{% endblock content%}
class MovieDetailView(DetailView):
model = Movie
template_name = ‘movie_detail.html’
context_object_name = ‘detail’
pk_url_kwarg = ‘movie_pk’
there is a video preview in html, there is a link to the video when I view the code through the browser, but the video does not start