python - How to use user profiles with MongoEngine (Django)? -



python - How to use user profiles with MongoEngine (Django)? -

so, i'm trying build simple site mongodb database , django (using mongoengine), stuck trying understand how user profiles work. can save mongo_auth.mongouser document database fine, when comes downwards saving profile, i'm not doing right thing. here user profile model/document trying setup mongouser:

from mongoengine.django.auth import user mongoengine import * [...] class userprofile(document): user = embeddeddocumentfield('user') telephone = models.charfield(max_length=30,null=true,blank=true) address = models.charfield(max_length=100, null=true, blank=true) birthdate = models.datefield(null=true, blank=true) def create_user_profile(sender, instance, created, **kwargs): if created: profile, created = userprofile.objects.get_or_create(user=instance) post_save.connect(create_user_profile, sender=user)

in django relational databases, userprofile models.model , user field onetoone relationship, don't know how map mongouser, guessed next lines:

class userprofile(document): user = embeddeddocumentfield('user')

but, apparently, it's not right since django can't load profile:

unable load profile model, check auth_profile_module in project settings

i think settings.py configured correctly since can save mongouser fine (without profile), , next line tells django find userprofile:

auth_profile_module = 'comptes.userprofile'

i still new django , mongodb, help appreciated.

thanks!

you must utilize mongoengine.fields.referencefield. this

class userprofile(document): user = referencefield('user')

python django mongodb authentication mongoengine

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -