简体   繁体   English

带有Django应用引擎的Django-nonrel无法访问管理界面

[英]Django-nonrel with django app engine cannot access the admin interface

I have a Django app which I am trying to get to Django-nonrel so that I can get it on GAE. 我有一个Django应用,正尝试使用Django-nonrel,以便可以在GAE上获取它。 The problem though is that numerous times have I tried creating superuser for the admin interface still when I do syncdb , it shows me: 问题是,当我执行syncdb时 ,仍然无数次尝试尝试为管理界面创建超级用户,这表明:

You just installed Django's auth system, which means you don't have any superusers defined. 您刚刚安装了Django的auth系统,这意味着您没有定义任何超级用户。

everytime.Also, I am never able to login into my admin interface by the created superuser. 而且,我永远无法由创建的超级用户登录到我的管理界面。 Also, when I do this: 另外,当我这样做时:

 python manage.py shell >>> from django.contrib.auth.models import User >>> User.objects.all() [] 

SO no users are created it seems. 因此,似乎没有用户创建。 I tried to look for the solution and and had a look at a few questions like these: 我尝试寻找解决方案,并查看了一些类似以下的问题:

django-nonrel and the admin page django-nonrel和管理页面

and a few others. 和其他一些。 Didn't help either. 也没有帮助。 I would like to mention that I am using zip downloaded version of django-nonrel 1.6 and djangoappengine by copying them in my project directory 我想提及的是,我正在使用django-nonrel 1.6和djangoappengine的zip下载版本,方法是将它们复制到我的项目目录中

Just for reference my settings.py and app.yaml files are as follows: 仅供参考,我的settings.pyapp.yaml文件如下:

Settings.py: Settings.py:

 # Django settings for flogin project. # Initialize App Engine and import the default settings (DB backend, etc.). # If you want to use a different backend you have to remove all occurences # of "djangoappengine" from this file. from djangoappengine.settings_base import * import sys sys.path.insert(0, 'libs') ADMINS = ( # ('Your Name', 'your_email@example.com'), ) MANAGERS = ADMINS # Activate django-dbindexer for the default database DATABASES['default'] = {'ENGINE': 'dbindexer', 'TARGET': DATABASES['default']} AUTOLOAD_SITECONF = 'indexes' # Hosts/domain names that are valid for this site; required if DEBUG is False # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts ALLOWED_HOSTS = [] # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. # In a Windows environment this must be set to your system time zone. TIME_ZONE = 'America/Chicago' # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'en-us' SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale. USE_L10N = True # If you set this to False, Django will not use timezone-aware datetimes. USE_TZ = False # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/var/www/example.com/media/" MEDIA_ROOT = '' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://example.com/media/", "http://media.example.com/" MEDIA_URL = '' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/var/www/example.com/static/" STATIC_ROOT = '' # URL prefix for static files. # Example: "http://example.com/static/", "http://static.example.com/" STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = ( # Put strings here, like "/home/html/static" or "C:/www/django/static". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) # Make this unique, and don't share it with anybody. SECRET_KEY = 'some key not shown here' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) MIDDLEWARE_CLASSES = ( # This loads the index definitions, so it has to come first 'autoload.middleware.AutoloadMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # Uncomment the next line for simple clickjacking protection: 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) ROOT_URLCONF = 'flogin.urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', #'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'oauth2_provider', 'social.apps.django_app.default', 'rest_framework_social_oauth2', 'flogin', 'djangoappengine', # Uncomment the next line to enable the admin: 'django.contrib.admin', # Uncomment the next line to enable admin documentation: 'django.contrib.admindocs', 'djangotoolbox', 'autoload', 'dbindexer', # djangoappengine should come last, so it can override a few manage.py commands ) # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to # the site admins on every HTTP 500 error when DEBUG=False. # See http://docs.djangoproject.com/en/dev/topics/logging for # more details on how to customize your logging configuration. LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' } }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' } }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, } } 

app.yaml 的app.yaml

 application: flogin version: 1 runtime: python27 api_version: 1 threadsafe: yes builtins: - remote_api: on inbound_services: - warmup handlers: - url: /_ah/queue/deferred script: djangoappengine.deferred.handler.application login: admin - url: /_ah/stats/.* script: djangoappengine.appstats.application - url: /media/admin static_dir: django/contrib/admin/media expiration: '0' - url: /.* script: djangoappengine.main.application 

Ok, I had the same problem and I found a reason why it's happening. 好的,我遇到了同样的问题,并且找到了发生这种情况的原因。 When you run manage.py with any command except 'runserver' djangoappengine creates in-memory database for that and I think it's a bug in djangoappengine here, so no changes is made to local database for 'syncdb' or 'shell' or 'createsuperuser', btw I use v1.7.1 of djangoappengine. 当您使用除“ runserver”以外的任何命令运行manage.py时,djangoappengine会为此创建内存数据库,并且我认为这是djangoappengine中的错误,因此对于“ syncdb”或“ shell”或“ createsuperuser”,本地数据库不会进行任何更改',顺便说一句,我使用的是djangoappengine v1.7.1。 When you run 'runserver' command, it first creates in-memory database, but then recreates it with proper local stored one. 当您运行“ runserver”命令时,它首先创建内存数据库,然后使用适当的本地存储数据库重新创建它。

So, how to fix it? 那么,如何解决呢? The simpliest way is to patch djangoappengine/db/stubs.py, 最简单的方法是修补djangoappengine / db / stubs.py,

In the method def activate_stubs(self, connection): replace 在方法def activate_stubs(self, connection):替换

self.activate_test_stubs(connection)

with

from .base import DATASTORE_PATHS self.activate_test_stubs(connection, DATASTORE_PATHS['datastore_path'])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM