3π
β
No need to mess with **
in register
method. What you want to do is simply pass dictionary to register
method:
user = backend.register( request, userdata ) # you need to pass request as definition says
def register( self, request, userdata ): # note lack of **
logging.debug("backend.register")
logging.debug( userdata ) # should work as expected
username, email, password = userdata['email'], userdata['email'], userdata['password1']
π€cji
3π
Judging by the methodβs signature:
- you need to unpack your dictionary
- you need to pass relevant
request
variable
Something like this:
backend.register(request, **userdata)
Assuming register
is a method on backend
instance.
π€SilentGhost
- [Django]-How to make django register users with emails instead of username
- [Django]-How to add custom user fields of dj_rest_auth package
0π
this perfectly work
class Logging():
def debug(self,f):
print f
class DefaultBackend(object):
def register(self, request, **kwargs):
logging.debug("backend.register")
logging.debug(kwargs)
username, email, password = kwargs['email'], kwargs['email'], kwargs['password1']
class Request:
def __init__(self):
self.session = {}
request = Request()
logging=Logging()
request.session['temp_data']={'password1': u'a', 'email': u'my@email.com'}
request.session['backend']=DefaultBackend()
data = request.session['temp_data']
email = data['email']
logging.debug(email)
password1 = data['password1']
userdata = {'email': email, 'password1': password1}
logging.debug(userdata)
backend = request.session['backend']
logging.debug(backend)
user = backend.register(request,**userdata)
π€Xavier Combelle
- [Django]-Error in PIL installed with PIP β Django,Python
- [Django]-Problems with deploying fabric for mezzanine
- [Django]-Django Class Based view calling an other one
- [Django]-Errno 13 Permission denied Django Upload File
Source:stackexchange.com