0

私は Django を初めて使用するので、通常、ほとんどの問題の原因は私にありますが、django-guardian 1.3 アプリがインストールされない理由がわかりません。仮想環境で Django 1.7 を使用しています。私の OS は Windows 8.1 です。

pythonhosted.org/django-guardian/installation.htmlのインストール手順とpythonhosted.org/django-guardian/configuration.htmlの構成手順に従いましたが、プログラムを実行しようとするとエラーが発生します。

「guardian」、ANONYMOUS_USER_ID、およびバックエンドを settings.py に追加しました

"""
Django settings for VolunteerManager project.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'Super Super Secret'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []
ANONYMOUS_USER_ID = -1

# Application definition

INSTALLED_APPS = (
#DEFAULT APPS
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

#THIRD PARTY APPS
    'guardian',
    'registration',
        #Copyright (c) 2007-2012, James Bennett
        #All rights reserved.
    'django.contrib.sites',

#LOCAL APPS
    'Volunteer',
)

ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window;
REGISTRATION_AUTO_LOGIN = True # Automatically log the user in.

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',
)

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend', 
    'guardian.backends.ObjectPermissionBackend',
)

ROOT_URLCONF = 'VolunteerManager.urls'


#ANONYMOUS_USER_ID = 'VOLUNTEER_USER_ID'

WSGI_APPLICATION = 'VolunteerManager.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'volunteer',
        'USER': 'root',
        'PASSWORD': '$',
        'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
        'PORT': '3306',
    }
}

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_URL = '/static/'

TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]

LOGIN_REDIRECT_URL = '/home/'

SITE_ID = 1

IMGURで利用可能なエラー画像

仮想環境に Django-guardian がインストールされているようですが、まだ見つかりません。私が間違ったことをしたかもしれないアイデアはありますか?(または、Django のオブジェクトごとのパーミッションに関する他の提案はありますか?) ありがとうございます!

更新: 問題を virtualenv に絞り込みました。virtualenv を使用せずにモジュールをインストールすると、django はモジュールを適切に検出します。正確に何が間違っていたのかはまだわかりませんが、現時点では 1 つのプロジェクトにしか取り組んでいないことを考えると、これでうまくいきます。

4

2 に答える 2