python - django update view password and ForeignKey -


i use django update/create view , have problems:

  1. how can update/create password? - can show old password

it doesn't save new 1 django hash algorithm password

ignored , user cant log in anymore.

class update(updateview):     model = user     fields = ['username', 'password'] 
  1. how can update/create foreign key?

  2. is there way custom fields? i.e. show them

radio/checkbox/password?

thx

i can show old password doesn't save new 1 django hash algorithm password ignored , user cant log in anymore.

that's because security, django doesn't store raw passwords, stores hash of raw password, sufficient tell if user entered correct password

to set password use user.set_password()

user = request.user # or user source user.set_password('raw password string') 

so instead of changing field directly, change password above store hash (not raw password), , don't bother "showing old password", secure system won't able to

https://docs.djangoproject.com/en/1.8/ref/contrib/auth/#django.contrib.auth.models.user.set_password


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

Fatal error: Call to undefined function menu_execute_active_handler() in drupal 7.9 -

c# - Get rid of xmlns attribute when adding node to existing xml -