2👍
MongoEngine now supports AUTH_PROFILE_MODULE
https://github.com/ruandao/mongoengine_django_contrib_auth/blob/master/models.py#L134-163
4👍
We just extended the User class.
class User(MongoEngineUser):
def __eq__(self, other):
if type(other) is User:
return other.id == self.id
return False
def __ne__(self, other):
return not self.__eq__(other)
def create_profile(self, *args, **kwargs):
profile = Profile(user=self, *args, **kwargs)
return profile
def get_profile(self):
try:
profile = Profile.objects.get(user=self)
except DoesNotExist:
profile = Profile(user=self)
profile.save()
return profile
def get_str_id(self):
return str(self.id)
@classmethod
def create_user(cls, username, password, email=None):
"""Create (and save) a new user with the given username, password and
email address.
"""
now = datetime.datetime.now()
# Normalize the address by lowercasing the domain part of the email
# address.
# Not sure why we'r allowing null email when its not allowed in django
if email is not None:
try:
email_name, domain_part = email.strip().split('@', 1)
except ValueError:
pass
else:
email = '@'.join([email_name, domain_part.lower()])
user = User(username=username, email=email, date_joined=now)
user.set_password(password)
user.save()
return user
- [Django]-Downgrade Website from Django 1.4 to Django 1.3
- [Django]-How to solve "table "auth_permission" already exists" error when the database is shared among two Django projects
- [Django]-Generating a date relative to another date in Django template
- [Django]-Django Heroku and postgresql
0👍
In Django 1.5 you can now use a configurable user object, so that’s a great reason to not use a separate object and I think it’s safe to say that it is no longer considered bad practice to extend the User model if you are on Django <1.5 but expecting to upgrade at some point. In Django 1.5, the configurable user object is set with:
AUTH_USER_MODEL = 'myapp.MyUser'
in your settings.py. If you are changing from a previous user configuration, there are changes that impact collection naming etc. If you don’t want to upgrade to 1.5 just yet, you can extend the User object for now, and then update it further later when you do upgrade to 1.5.
https://docs.djangoproject.com/en/dev/topics/auth/#auth-custom-user
N.B. I have not personally tried this in Django 1.5 w/ MongoEngine, but expect it should support it.
- [Django]-Can this variable really be "referenced before assignment"
- [Django]-Integrating Django with Amazon's Database 'SimpleDB'
- [Django]-Whats the correct way to use and refer to a slugfield in a django 1.3
- [Django]-Automatically generating Piratespeak .po/gettext/translations for i18n testing?
- [Django]-Overriding methods for defining custom model field in django