그래서 저는 문제가 생겨서 스스로 등록 백엔드를 작성하려고합니다. 은 내가HttpResponse 객체에는 속성이 없습니다. get_absolute_url
을 get_absolute_url가 없습니다 얻고이 문제를 해결하는 방법을 모른다. 여기에 내 코드는 다음과 같습니다HttpResponse에이 개체가 어떤 속성이
class MyRegistrationBackend(object):
def register(self, request, **kwargs):
username, email, password = kwargs['username'], kwargs['email'], kwargs['password1']
encode_drupal = DrupalPasswordHasher()
password = encode_drupal.create(str(password),"E","LOhihi6WNUA.") #drupal style hasher
print "sha512 pass: ", password
#ask if user is already registered
req = urllib2.Request(settings.DJANGO_SERVER+"/api/stats/customuser/"+username+"/?format=json",
headers = {"Authorization": basic_authorization(settings.DJANGO_OAUTH_USERNAME, settings.DJANGO_OAUTH_PASSWORD),"Content-Type": "application/json"}
)
resp = json.loads(urllib2.urlopen(req).read())
print resp
if resp['username']!='':
#do something
else:
if resp['password'] != password: #password does not match received pass
print "wrong credentials"
return render_to_response('registration/error.html')
역 추적 :
Environment:
Request Method: POST
Request URL: http://192.168.1.77:8000/accounts/register/
Django Version: 1.4.2
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'registration',
'administration',
'tastypie',
'south',
'social_auth',
'django_extensions',
'djcelery',
'braces',
'django.contrib.admin',
'django.contrib.admindocs')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.gzip.GZipMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'youbeqadmin.middleware.crossdomainxhr.XsSharing')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/registration/views.py" in register
189. to, args, kwargs = backend.post_registration_redirect(request, new_user)
File "/home/psychok7/git/mysite/mysite/backends.py" in post_registration_redirect
126. return (user.get_absolute_url(),(), {})
Exception Type: AttributeError at /accounts/register/
Exception Value: 'HttpResponse' object has no attribute 'get_absolute_url'
어떤 아이디어가? 나는 그것이
에는 render_to_response
함께 할 수있는 뭔가가 생각,하지만 난이 문제를 해결하는 방법을 잘 모릅니다.
UPDATE :
내가 없음을 반환하지 않는 경우, 내가 얻을
'NoneType'개체가 어떤 속성 'get_absolute_url'
이
전체 스택 추적 표시. 여기에는 운이 좋은 사람이 없습니다. – kirelagin
은 tracktrace를 추가했습니다 – psychok7
그래서, 어떻게'HttpResponse' 객체가'user'라고 불리는가? 실제로 작동하지 않는 코드 부분을 게시하지 않았 음을 분명히 볼 수 있기를 바랍니다. – kirelagin