video href for in class MovieDetailView(DetailView):

{% 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

Я не уверен, что правильно понял ваш вопрос - я предполагаю, что это может быть ограничение translate.google.com.

Я думаю, что вы пытаетесь получить URL-адрес загруженного файла. Если это так, то то, что вы ищете, это атрибут url поля.

Если я не понял вашего вопроса, это может помочь, если вы предоставите более подробную информацию о том, что именно вы пытаетесь сделать.

— And the original English text —

I’m not sure I’m understanding your question correctly - I’m guessing it may be a limitation of translate.google.com.

What I think you’re trying to do is get the url for an uploaded file. If so, then what you’re looking for is the url attribute of the field.

If I didn’t understand your question, it may help if you provided more details about exactly what you’re trying to do.

1 Like

Side note: When posting code, templates, tracebacks, etc, enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code (or traceback or template or whatever) then another line of ```. (I’ve fixed your original post above.)

What is the name of the FileField within the Movie model that stores the movie? It’s that attribute on which you use the .url reference, which you appear to have.

Ahh… You have:

But your url is defined as:

The name for the kwarg in the class must match the name of the parameter in the url.