"settings.DATABASES is improperly configured. [...]" when using neo4django.auth and neo4django.admin with only neo4j db

StackOverflow https://stackoverflow.com/questions/17214896

سؤال

I am building an application in Django 1.4.5 with neo4django (github version). I am currently trying to enable the admin interface as instructed on https://neo4django.readthedocs.org/en/latest/admin.html

With the following settings when i hit /admin I get the error settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

My settings.py includes the following

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.dummy',
    }
}
NEO4J_DATABASES = {
    'default' : {
        'HOST':'localhost',
        'PORT':7474,
        'ENDPOINT':'/db/data'
    }
}

AUTHENTICATION_BACKENDS = ('neo4django.auth.backends.NodeModelBackend',)

SESSION_ENGINE = ('django.contrib.sessions.backends.file')

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.request',
    'django.core.context_processors.i18n',
    'django.contrib.messages.context_processors.messages',
    'django.core.context_processors.static',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
)

INSTALLED_APPS = (
    'neo4django.auth',
    'django.contrib.sessions',
    'django.contrib.messages',
    'neo4django.admin', 
    'neo4django.contenttypes',
    'django.contrib.admin', 
    'django.contrib.contenttypes',
    'django.contrib.auth',
    'django.contrib.sites',
    'django.contrib.staticfiles',
    'my_app',
    'users',
)

my urls.py

from django.conf.urls import patterns, include, url
from neo4django import admin


admin.autodiscover()

urlpatterns = patterns('',
    url(r'^$', 'my_app.views.MainHomePage', name='home'),
    url(r'^admin/', include(admin.site.urls)),
)

my models.py

from neo4django.db import models 
from neo4django.auth.models import User

class Person(models.NodeModel):
    email = models.EmailProperty(required = True, unique = True, indexed = True)

    # Neo4J RelationShips
    user = models.Relationship(User, rel_type = 'is_user')

    def __unicode__(self):
        return u'%s' % (self.full_name.strip())

and my admin.py (as simple as it gets)

from django.contrib import admin
from neo4django.auth.models import User
from users.models import Person 

class UserAdmin(admin.ModelAdmin):
    pass

admin.site.register(User, UserAdmin)

class PersonAdmin(admin.ModelAdmin):
    pass

admin.site.register(Person, PersonAdmin)

I have tried to either use a mysql together with neo4j, but I will either get the no such table: django_site error, where I have to first run syncdb, at least for the django_site table to be created or I just keep being redirected back to admin login page after successful log in.

Can someone point me to the right direction or at least tell me if using only neo4j is possible or not?

هل كانت مفيدة؟

المحلول

For the database settings, I typically just use

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': ''
    }
}

I know it's annoying, but as long as you don't run syncdb, no sqlite file is created (and neo4django doesn't require syncdb anyway).

As far as the admin.py goes, I noticed you're importing from django- you need to be importing from neo4django. Try

from neo4django import admin
from users.models import Person

class PersonAdmin(admin.ModelAdmin):
    ...    

admin.site.register(Person, PersonAdmin)

EDIT:

One more tip - you'll probably want to set single=True on the user relationship, since a Person should only have one user. If a User should only have one person, I'd also set related_single=True, related_name='person' so you can access both as objects instead of managers.

نصائح أخرى

There you go:

https://docs.djangoproject.com/en/1.5/intro/tutorial01/#database-setup

You have bad ENGINE for database.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top