I’m having an issue with this following line of code getting passed a arguement with spaces inside it.
<a href="{% url graph_exercisename exercise_name=e.exercisename|slugify %}" class="button" >Graph</a>
When i cut the piece of code above out of the html file, the page compiles fine. It also compiles when an arg that doesn’t have a space in it is passed to exercise_name.
Here is my url pattern
urlpatterns = patterns('',
url('^exercises/(\d{1,6})/$', exercises,name='displayexercises'),
url('^workouts/$',workouts,name="displayworkouts"),
url('^graph/$',bodyweight_graph),
url('^graph/(?P<exercise_name>\w+)/$',graph_exercisename,name="graph_exercisename"),
)
and finally the view:
def graph_exercisename(request,exercise_name):
exercise_name = exercise_name.replace('-'," ").title()
exercises = Exercise.objects.filter(workout__user=request.user.id).filter(exercisename = exercise_name)
exercises = exercises.order_by('workout__workoutdate')[:10]
values = Rep_Table(exercises).table
return render(request,'graph.html',{'values':values})
What’s even more strange is that Django isn’t giving me any code on the error page at all, it just states that Django has encountered an error.
Thanks for the help!
Please change your url entry:
to: