1

I am trying to pass a numerical parameter through the url to my class based Django view method get within my class Quit. How do I go about doing this?

.js file code...

function restart_or_quit_game(){

    this.quit = function quit(number){
        if(number === 1){
            window.location.href='quit/1';
        }
    }
}

urls.py file...

urlpatterns = [
    url(r'^quit/(?P<id>\d+)$', Quit.as_view()),
    url(r'^$', Index.as_view()),
]

view file

class Quit(View):
    def get(self, request, id):
        print(id)
        return redirect('/')

What am I doing wrong?

wpercy
  • 9,636
  • 4
  • 33
  • 45
Erik Åsland
  • 9,542
  • 10
  • 30
  • 58

1 Answers1

1

Needed to import redirect with the following code. Everything works gravy now!

from django.shortcuts import render, redirect
Erik Åsland
  • 9,542
  • 10
  • 30
  • 58