Reputation: 5448
Hi I am trying to create a link with paremeter but I am getting an error (Page not found)
error
Reverse for 'hexcode' with arguments '('#d4cbd0',)' not found. 1 pattern(s) tried: ['hexcode/(?P<color>\\w)$']
template
{% for color in palette_dominant_color %}
<a href="{% url 'brandcolors:hexcode' color %}" style="text-decoration:none;color:inherit">
{{color}}
</a>
<br>
{% endfor %}
urls.py
url(r'^hexcode/(?P<color>\w)/$', ThemeView.as_view(), name="hexcode"),
views.py
class ThemeView(TemplateView):
template_name='fabric/theme.html'
def get_context_data(self, **kwargs):
context = super(ThemeView, self).get_context_data(**kwargs)
colors = Color.objects.filter(color=kwargs['color']).all()
return context
Upvotes: 0
Views: 184
Reputation: 599610
Your regex expects a single alphanumeric character, not a hash followed by several characters.
Upvotes: 2
Reputation: 1514
Your link should be:
<a href="{% url 'brandcolors:hexcode' color=color %}" style="text-decoration:none;color:inherit">{{color}}</a>
Upvotes: 1