"<UserProfile: ppokkutt>" needs to have a value for field "userprofile" before this many-to-many relationship can be used.
This last message suggests to me that the UserProfile is not saved before the signal is sent (from the django-registration plugin) to the custom backend (regbackend.py above) which attempts to update that non-existent entry with the locality. Here is the relevant code from django-registration views.py:
______________________________________________
def register(self, request, **cleaned_data):
"""
Given a username, email address and password, register a new
user account, which will initially be inactive.
Along with the new ``User`` object, a new
``registration.models.RegistrationProfile`` will be created,
tied to that ``User``, containing the activation key which
will be used for this account.
After the ``User`` and ``RegistrationProfile`` are created and the activation email is sent, the signal
``registration.signals.user_registered`` will be sent, with
the new ``User`` as the keyword argument ``user`` and the
class of this backend as the sender.
"""
username, email, password = cleaned_data['username'], cleaned_data['email'], cleaned_data['password1']
if Site._meta.installed:
site = Site.objects.get_current()
else:
site = RequestSite(request)
new_user = RegistrationProfile.objects.create_inactive_user(username, email, password, site)
signals.user_registered.send(sender=self.__class__,
user=new_user,
request=request)
return new_user
______________________________________________
and from models.py:
______________________________________________
def create_inactive_user(self, username, email, password,
site, send_email=True):
"""
Create a new, inactive ``User``, generate a
``RegistrationProfile`` and email its activation key to the
``User``, returning the new ``User``.
By default, an activation email will be sent to the new
user. To disable this, pass ``send_email=False``.
"""
new_user = User.objects.create_user(username, email, password)
new_user.is_active = False
new_user.save()
registration_profile = self.create_profile(new_user)
if send_email:
registration_profile.send_activation_email(site)
return new_user
create_inactive_user = transaction.commit_on_success(create_inactive_user)
______________________________________________
Any thoughts would be much appreciated!
Matt