Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I use HttpResponseRedirect I get TypeError: quote_from_bytes() expected bytes in Django

Tags:

python

django

When trying to implement a custom get_success_url method in python, Django throws a TypeError: quote_from_bytes()error. For example:

class SomeView(generic.CreateView):

    #... 

    def get_success_url(self):
        return HttpResponseRedirect(reverse('index'))
like image 250
nmu Avatar asked Sep 14 '18 14:09

nmu


1 Answers

get_success_url doesn't return an HttpResponseRedirect instead it should return the url you want to redirect to. So you can just return reverse('index'):

def get_success_url(self):
    return reverse('index')
like image 183
nmu Avatar answered Oct 25 '22 01:10

nmu