I have a list of items in an html file as follows:
{% extends 'base.html' %}
{% block Content %}
<div id="movie_list">
{% for movie in movies %}
<p class="movie-title"><a href="/movie/{{ movie.slug }}/">{{ movie.name }}</a> </p>
{% endfor %}
</div> {% endblock %}
It displays a list of movies name which every item in this list is a link! I try to send a request to server to see a specific movie according to the href
attribute in the <a>
tag.
The model handles this request is as follows:
def SpecificMovie(request, movie_slug):
movie = Movie.objects.get(slug=movie_slug)
context = {'movies': movie}
return render_to_response('single_movie.html', context, context_instance=RequestContext(request))
It responds to the request according the movie_slug
passed into it!
the single_movie.html
file is as follows:
{% extends 'base.html' %}
{% block Content %}
<div id="single_moive">
<p class="movie-title">Name: {{ movies.name }}</p>
<p class="movie-title">Des: {{ movies.description }}</p>
<p class="movie-title">Country: {{ movies.country }}</p>
</div>
{% endblock %}
and my urlpatterns
var is as follows:
urlpatterns = patterns('',
(r'^$', TemplateView.as_view(template_name='index.html')),
(r'^admin/', include(admin.site.urls)),
(r'^movie/$', 'movie_page.views.MoviesAll'),
(r'^movie/(?P<movie_slug>.)/$', 'movie_page.views.SpecificMovie'),
)
But when I click on each item in receive an error saying that there is miss match in the url pattern. An snapshot of the page is as follows:
as you can see everything seems ok! but I don't know what the problem is! I read the following links(link1,link2, link3) but Thanks for any comments.