i want to add a url to my project that would get the id of a video and append it to url like this http://127.0.0.1:8000/course/learn-angular/contents/?lecture=1
<a href="?lecture={{v.serial_number}}"
instead of the regular django {% url '?lecture={{v.serial_number}}' %}
.
when i do this <a href="{% url '?lecture={{v.serial_number}}' %}">
that is when i get this error Reverse for '?lecture={{v.serial_number}}' not found. '?lecture={{v.serial_number}}' is not a valid view function or pattern name.
.
NOTE: when i add the url as ?lecture={{v.serial_number}}
is show this error when i click on the url Page not found (404) Directory indexes are not allowed here
and all these are happening i think becuase i have this line <base href="{% static '/' %}">
in my base.html where i am extending all my static files from.
And if you asking why i have this line base href="{% static '/' %}">
, it's becuase my static files are not loading up as usual, it keep showing a MIME type not supoorted error, refused to apply 127.0.0.1:8000/assets/css/style.css so the only way i could fix this was to add that line to my base.html.
Back to the main question, what is the right way to write tihs url withot getting this error Page not found (404) Directory indexes are not allowed here.
CodePudding user response:
You need to pass in the url name for the urlpattern that matches /course/learn-angular/contents/
and then pass in the query params for the lecture id ?lecture=1
<a href="{% url 'name_for_route' %}?lecture={{v.serial_number}}">