i trying create blog using django , mongodb in aws ec2 instance
and in file models.py, making following changes
from datetime import datetime mongoengine import * mongoengine.django.auth import user django.core.urlresolvers import reverse class post(document): user = referencefield(user, reverse_delete_rule=cascade) title = stringfield(max_length=200, required=true) text = stringfield(required=true) text_length = intfield() date_modified = datetimefield(default=datetime.now) is_published = booleanfield() django.core.urlresolvers import reverse class post(document): user = referencefield(user, reverse_delete_rule=cascade) title = stringfield(max_length=200, required=true) text = stringfield(required=true) text_length = intfield() date_modified = datetimefield(default=datetime.now) is_published = booleanfield() def __unicode__(self): return self.title def save(self, *args, **kwargs): self.text_length = len(self.text) return super(post, self).save(*args, **kwargs) def get_absolute_url(self): return reverse('detail', args=[self.id]) def get_edit_url(self): return reverse('update', args=[self.id]) def get_delete_url(self): return reverse('delete', args=[self.id])
and, error
traceback (most recent call last): file "models.py", line 7, in <module> mongoengine.django.auth import user importerror: no module named django.auth
and, in settings.py file, making following changes
import os mongoengine import * project_root = os.path.abspath(os.path.dirname(__file__)) # security warning: don't run debug turned on in production! debug = true template_debug = true allowed_hosts = ['54.149.63.203', 'localhost', '127.0.0.1'] # application definition installed_apps = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', 'ljblog', 'django_extensions', 'mongoengine.django.mongo_auth', ) middleware_classes = ( 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.auth.middleware.sessionauthenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', 'django.middleware.clickjacking.xframeoptionsmiddleware', 'django.middleware.security.securitymiddleware', ) root_urlconf = 'lj.urls' templates = [ { 'backend': 'django.template.backends.django.djangotemplates', 'dirs': [], 'app_dirs': true, 'options': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] wsgi_application = 'lj.wsgi.application' databases = { 'default': { 'engine': 'django.db.backends.dummy', 'name': '', 'user': '', 'password': '', 'host': '55.181.26.33', //mongodb ip address 'port': '27017', } } language_code = 'en-us' time_zone = 'utc' use_i18n = true use_l10n = true use_tz = true media_root = os.path.join(project_root, '..', 'media') media_url = '/media/' static_root = os.path.join(project_root, '..', 'static') static_url = '/static/' staticfiles_dirs = ( os.path.join(project_root, 'static'), ) template = ( os.path.join(project_root, 'templates'), ) authentication_backends = ( 'mongoengine.django.auth.mongoenginebackend', ) session_engine = 'mongoengine.django.sessions' auth_user_model = 'mongo_auth.mongouser' mongoengine_user_document = 'mongoengine.django.auth.user' mongo_database_name = 'lj_blog' mongoengine import connect connect(mongo_database_name)
so, how can resolve import error?
django support removed mongoengine in 0.10.0. might able earlier version work, might not support recent versions of django.
with mongoengine 0.10 can see
/usr/lib/python2.7/site-packages/mongoengine/
will not have django package in it. install mongoengine 0.9 using
sudo pip install mongoengine==0.9
and django package (support or extension) available.
Comments
Post a Comment