0

Im trying to pass an id in my URL, it's created in the js and I need to pass it in my render so I can use it in a Jquery on the new page. is this possible?

JS

results ="'results/"+this.pk+"'";

urls

url(r'^personnel/results/(\d*)/$', 'resource.views.personnel_results'),

resultant URL /personnel/results/1/

and my view

def personnel_results(request):
    return render(request, 'personnel-results.html',)
1
  • What error message did you receive? Commented Jan 29, 2016 at 14:47

1 Answer 1

1

You say you want to pass it, but you have avoided doing that in your view. The third parameter to render, which you explicitly miss out, is the dictionary of keys and values to pass to the template. You need to accept the variable in your view, and pass it in the context.

def personnel_results(request, pk):
    return render(request, 'personnel-results.html', {'pk': pk})

This is well covered in the tutorial - you should go back and do that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.