I am getting the following error while encrypting the password using bz2
module using Python. Here I am saving that encrypted value inside DB.
Error:
ProgrammingError at /signsave/
You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.
Request Method: POST
Request URL: http://127.0.0.1:8000/signsave/
Django Version: 1.11.2
Exception Type: ProgrammingError
Exception Value:
You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.
Here is my code:
def signsave(request):
"""This function helps to save signup data"""
if request.method == 'POST':
name = request.POST.get('uname')
password = request.POST.get('pass')
con_pass = request.POST.get('conpass')
new_pass = bz2.compress(password)
if password == con_pass:
passw = User(
uname=name,
password=new_pass,
raw_password=password,
)
passw.save()
message = "Registered successfully"
return render(request, 'bookingservice/login.html', {'msg': message})
else:
message = "The password did not match "
return render(request, 'bookingservice/signup.html', {'msg': message})
Here when I am trying to save the encrypted value those errors are coming.