I think I should provide some more details about what I want to do.
my settings.py:
INSTALLED_APPS = (
# ...
"users",
# ...
)
AUTH_USER_MODEL = 'users.User'
AUTH_PROFILE_MODULE = "users.Profile"
ACCOUNTS_PROFILE_FORM_EXCLUDE_FIELDS = (
"first_name",
"last_name",
)
ACCOUNTS_NO_USERNAME = True
ACCOUNTS_VERIFICATION_REQUIRED = True
users/models.py:
class AbstractUser(AbstractBaseUser, PermissionsMixin, AbstractForumUser): #
AbstractForumUser inherit from Spirit
email = models.EmailField(_('email address'), max_length=254, unique=
True, db_index=True) # email is used for log in
username = models.CharField(_('nickname'), max_length=64,
help_text=_('How do people call you?'),
unique=True) # username is used as nickname and is optional
biography = models.TextField(_('biography'),
help_text=_('Let others know a bit about
you'), blank=True) # custom field
# the rest of the class doesn't change
class User(AbstractUser):
class Meta(AbstractUser.Meta):
swappable = 'AUTH_USER_MODEL'
class Profile(models.Model):
user = models.OneToOneField("User")
username = models.CharField(_('nickname'), max_length=64,
help_text=_('How do people call you?'),
unique=True)
biography = models.TextField(_('biography'),
help_text=_('Let others know a bit about
you'), blank=True)
This works and the fields Nickname and Biography show up in the sign in and
user profile form.
But the fields are not related with the fields from the user model so
username is not syncronized,
but I need this field also for Spirit which uses the AUTH_USER_MODEL.
So I try to make some relations:
class Profile(models.Model):
user = models.OneToOneField("User")
username = models.ForeignKey(User, related_name='+', to_field='username'
help_text=_('How do people call you?'),
verbose_name=_('nickname'))
biography = models.ForeignKey(User, related_name='+', to_field=
'biography'
help_text=_('Let others know a bit about
you'), verbose_name=_('biography'))
and
class Profile(models.Model):
user = models.OneToOneField(User)
username = user.username
biography = user.biography
which both doesn't work.
The best would be, if Mezzanine would inject the custom fields directly
from the custom user model into ProfileForm, so I have not to
use AUTH_PROFILE_MODULE at all.
--
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.