creating a registration profile in python django -
my goal django application upon registration, users able use site, prompt them later verify email (activate it). send them email verification email register, , again if can't find email.
i'm using django 1.7.8
, django-registration-redux
.
here's landing page view:
from django.shortcuts import render django.http import httpresponseredirect django.core.urlresolvers import reverse django.contrib.auth import authenticate django.contrib.auth import login registration import signals registration.models import registrationmanager drivers.forms import myusercreationform def create_registration_profile(user, request, **kwargs): user.backend = 'django.contrib.auth.backends.modelbackend' login(request, user) reg_manager = registrationmanager() reg_profile = reg_manager.create_profile(user) reg_profile.save() print "callback reached!" signals.user_registered.connect(create_registration_profile) def landing(request): if request.method == 'post': form = myusercreationform(request.post) if form.is_valid(): new_user = form.save() new_user = authenticate(email=form.cleaned_data['email'], password=form.cleaned_data['password1']) new_user.username = new_user.email # custom user has no username, email signals.user_registered.send(sender='landing', user=new_user, request=request) login(request, new_user) return httpresponseredirect(reverse("myapp:dashboard")) else: print form.errors else: form = myusercreationform() return render(request, "landing.html", { 'registration_form': form, })
unfortunately, fails on creation of registrationprofile
:
request method: post request url: http://localhost:8000/ django version: 1.7.8 python version: 2.7.5 installed applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'registration', 'macros', 'myapp', 'debug_toolbar') installed middleware: (u'debug_toolbar.middleware.debugtoolbarmiddleware', 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.auth.middleware.sessionauthenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', 'django.middleware.clickjacking.xframeoptionsmiddleware') traceback: file "/users/me/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 111. response = wrapped_callback(request, *callback_args, **callback_kwargs) file "/users/me/code/myapp/myapp_web/myapp_web_project/views.py" in landing 29. signals.user_registered.send(sender='landing', user=new_user, request=request) file "/users/me/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/dispatch/dispatcher.py" in send 198. response = receiver(signal=self, sender=sender, **named) file "/users/me/code/myapp/myapp_web/myapp_web_project/views.py" in create_registration_profile 16. reg_profile = reg_manager.create_profile(user) file "/users/me/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/registration/models.py" in create_profile 115. activation_key=activation_key) file "/users/me/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method 92. return getattr(self.get_queryset(), name)(*args, **kwargs) file "/users/me/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/db/models/query.py" in create 370. obj = self.model(**kwargs) exception type: typeerror @ / exception value: 'nonetype' object not callable
any ideas?
Comments
Post a Comment