Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom user model problem #531

Closed
berkaytheunicorn opened this issue Dec 4, 2013 · 11 comments
Closed

custom user model problem #531

berkaytheunicorn opened this issue Dec 4, 2013 · 11 comments
Milestone

Comments

@berkaytheunicorn
Copy link

in auth.py
from .mongo_auth import get_user_document

this raise import error

i changed it with

from .mongo_auth.models import get_user_document

so far so good.

rozza added a commit that referenced this issue Dec 4, 2013
@rozza rozza closed this as completed Dec 4, 2013
@rozza
Copy link
Contributor

rozza commented Dec 4, 2013

Apologies - 0.8.6 released

@andialbrecht
Copy link

With 0.8.6 I get the following traceback when running "manage.py runserver":

./manage.py runserver
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 280, in execute
    translation.activate('en-us')
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 130, in activate
    return _trans.activate(language)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 188, in activate
    _active.value = translation(language)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 177, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch
    app = import_module(appname)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/social/apps/django_app/__init__.py", line 13, in <module>
    from social.apps.django_app.utils import load_strategy
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/social/apps/django_app/utils.py", line 18, in <module>
    Storage = module_member(STORAGE)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/social/utils.py", line 21, in module_member
    module = import_module(mod)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/social/utils.py", line 15, in import_module
    __import__(name)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/social/apps/django_app/me/models.py", line 28, in <module>
    'mongoengine.django.auth.User'
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/social/utils.py", line 21, in module_member
    module = import_module(mod)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/social/utils.py", line 15, in import_module
    __import__(name)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/mongoengine/django/auth.py", line 12, in <module>
    from .mongo_auth.models import get_user_document
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/mongoengine/django/mongo_auth/models.py", line 97, in <module>
    class MongoUser(models.Model):
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/django/db/models/base.py", line 144, in __new__
    new_class.add_to_class(obj_name, obj)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/django/db/models/base.py", line 264, in add_to_class
    value.contribute_to_class(cls, name)
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/mongoengine/django/mongo_auth/models.py", line 67, in contribute_to_class
    self.model = get_user_document()
  File "/home/andi/.virtualenvs/htapp/local/lib/python2.7/site-packages/mongoengine/django/mongo_auth/models.py", line 30, in get_user_document
    return getattr(module, name[dot + 1:])
AttributeError: 'module' object has no attribute 'User'

It seems that get_user_document is imported too early in auth.py. During import of models.py "contribute_to_class" is called, which in turn tries to import auth.User which isn't defined at this point.

@denisvlr
Copy link

I get the exact same error. @andialbrecht did you find a solution?

@andialbrecht
Copy link

@denisvlr no, I had no time to investigate further as I'm using it in a toy project which is very low on my priority list. For now I've justed pinned to revision 16dcf78

@mgoffin
Copy link

mgoffin commented Dec 12, 2013

Just hit this today myself. I might have time tomorrow to look into it but I'm not sure.

@budowski
Copy link

budowski commented Jan 7, 2014

Hey guys - I had the same exception - opened issue #545 for this with a quick fix (see issue details for this).

@smalliao
Copy link

Hi, I have an issue. When I run the django project with mongoengine, it showed an error message:'module' object has no attribute 'User'
Django Version: 1.6.1
Exception Type: AttributeError
Exception Value:
'module' object has no attribute 'User'
Exception Location: /usr/local/lib/python2.7/dist-packages/mongoengine/django/mongo_auth/models.py in get_user_document, line 30
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/home/xinru/projects/market']

I wonder why it would get such an error. Could anybody tell me why? Thanks in advance.

@budowski
Copy link

Yes, see issue #545 for a quick fix. Hopefully they'll do an official
release of this soon.
On Jan 13, 2014 9:05 AM, "smalliao" notifications@github.com wrote:

Hi, I have an issue. When I run the django project with mongoengine, it
showed an error message:'module' object has no attribute 'User'
Django Version: 1.6.1
Exception Type: AttributeError
Exception Value:

'module' object has no attribute 'User'
Exception Location:
/usr/local/lib/python2.7/dist-packages/mongoengine/django/mongo_auth/models.py
in get_user_document, line 30
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:

['/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/home/xinru/projects/market']

I wonder why it would get such an error. Could anybody tell me why? Thanks
in advance.


Reply to this email directly or view it on GitHubhttps://github.com//issues/531#issuecomment-32150703
.

@smalliao
Copy link

That's strange, in my local ubantu system, it runs ok. But in the server's, the problem is as I mentioned before. Is the reason different version of mongoengine of something else?

@budowski
Copy link

Yes, it's only on MongoEngine 0.8.5 and 0.8.6.
On Jan 13, 2014 9:13 AM, "smalliao" notifications@github.com wrote:

That's strange, in my local ubantu system, it runs ok. But in the
server's, the problem is as I mentioned before. Is the reason different
version of mongoengine of something else?


Reply to this email directly or view it on GitHubhttps://github.com//issues/531#issuecomment-32150988
.

@smalliao
Copy link

Yes, I've fixed it. You're very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants