1๐
I figured out a way to make this work although I am sure there is a better way to do this.
I got rid of the json dumb and just cast to a string
views.py
newlink = []
links = CreatedScoreboardUnique.objects.filter(players=request.user)
for link in links:
newlink.append(str(link.pk))
Then for javascript I replaced the extra characters when I JSON.parse to get rid of the errors I was getting
javascript
function nextScoreboard(){
var links = JSON.parse("{{links}}".replace(/'/g,'"'))
var currId = "{{scoreboard.unique_id}}"
for(i = 0; i < links.length; i++){
if(links[i] == currId){
if(i+1 != links.length){
window.location.href = "http://127.0.0.1:8000/scoreboard/" + links[i+1]
} else {
window.location.href = "http://127.0.0.1:8000/scoreboard/"
}
}
}
}
So basically removing those โ characters allowed me to create the format I needed to make this work
๐คKyle Flannelly
Source:stackexchange.com