I have added one additional field, network
, in django-registration.
# in myproject.userprofile
from django.db import models
from django.contrib.auth.models import User
from myproject.network.models import Network
class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
network = models.ForeignKey(Network, unique=True)
# in settings.py
AUTH_PROFILE_MODULE = 'userprofile.UserProfile'
I don't need to add anything new to forms, as the network is generated based on the user's authorized email address.
So far, I have the following -- which is working, but is obviously not the best way to do it --
profile_additional = UserProfile.objects.create(user=User.objects.get(username=username),network=Network.objects.get(network=EmailList.objects.get(email=email).network))
Could you please show me the preferred way to do this same thing? I've read a couple tutorials on adding additional fields using signals, but can't seem to get it working myself. A code demonstrating how to do this would be much appreciated. Thank you.