python - How do you print a hash in Django 1.7 and store it in a database? -
i created hash going use later confirmation email logic this:
import hashlib, datetime, random def hash(request): username = 'johndoe' #inserted line simplify code random_str = str(random.random()).encode('utf-8') salt = hashlib.sha1(random_str).hexdigest()[:5] salted = (salt + username).encode('utf-8') activation_key = hashlib.sha1(salted).hexdigest() return render_to_response('ftest/display.html', activation_key)
my first question how print in html can see when html renders?
this doesn't seem work in display.html :
<p> activation key {{activation_key}} </p>
next, how define hash field in database? charfield like:
hash = models.charfield(max_length=200)
render_to_response expects dict :
return render_to_response('ftest/display.html', {'activation_key': activation_key})
a charfield right way go.
Comments
Post a Comment