请教一下问题

2019-04-02
1432 read

博主,可以跟你请教个问题吗?Django今天用manage.py启动项目的时候,报错了

LookupError: No installed app with label 'admin'.

不知道如何解决。

settings.py里面是注册了app的啊

```

import os

import sys


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))


# Quick-start development settings - unsuitable for production

# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/


# SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = 'bga5t#n-a9=mx^glxprkc#16c#z*n_t%o8jiwh(y*i+h7c!xo$'


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

DEBUG = True


ALLOWED_HOSTS = []



# Application definition


INSTALLED_APPS = (

    'django.contrib.admin',

    'django.contrib.auth',

    'django.contrib.contenttypes',

    'django.contrib.sessions',

    'django.contrib.messages',

    'django.contrib.staticfiles',

    'tinymce', # 富文本编辑器

    'user', # 用户模块

    'goods', # 商品模块

    'cart', # 购物车模块

    'order', # 订单模块

)


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 = 'dailyfresh.urls'


TEMPLATES = [

    {

        'BACKEND': 'django.template.backends.django.DjangoTemplates',

        'DIRS': [os.path.join(BASE_DIR, 'templates')],

        '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 = 'dailyfresh.wsgi.application'



# Database

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


DATABASES = {

    'default': {

        'ENGINE': 'django.db.backends.mysql',

        'NAME': 'dailyfresh_bj18',

        'USER': 'root',

        'PASSWORD': 'root',

        'HOST': '172.16.179.130',

        'PORT':3306,

    }

}


# django认证系统使用的模型类

AUTH_USER_MODEL='user.User'


# Internationalization

# https://docs.djangoproject.com/en/1.8/topics/i18n/


LANGUAGE_CODE = 'zh-hans'


TIME_ZONE = 'Asia/Shanghai'


USE_I18N = True


USE_L10N = True


USE_TZ = True



# Static files (CSS, JavaScript, Images)

# https://docs.djangoproject.com/en/1.8/howto/static-files/


STATIC_URL = '/static/'

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]


# 富文本编辑器配置

TINYMCE_DEFAULT_CONFIG = {

    'theme': 'advance',

    'width': 600,

    'height': 400,

}


# 发送邮件配置

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

# smpt服务地址

EMAIL_HOST = 'smtp.163.com'

EMAIL_PORT = 25

# 发送邮件的邮箱

EMAIL_HOST_USER = 'smartli_it@163.com'

# 在邮箱中设置的客户端授权密码

EMAIL_HOST_PASSWORD = 'smartli123'

# 收件人看到的发件人

EMAIL_FROM = '天天生鲜<smartli_it@163.com>'



# Django的缓存配置

CACHES = {

    "default": {

        "BACKEND": "django_redis.cache.RedisCache",

        "LOCATION": "redis://172.16.179.130:6379/9",

        "OPTIONS": {

            "CLIENT_CLASS": "django_redis.client.DefaultClient",

        }

    }

}


# 配置session存储

SESSION_ENGINE = "django.contrib.sessions.backends.cache"

SESSION_CACHE_ALIAS = "default"

```

pip3 install mysqlclient 报错 “/bin/sh: 1: mysql_config: not found”的解决方法
vue使用svg的简单记录

Comments

herschel #2

问题解决了,是我的Django版本的问题,谢谢大家

Heanny #1

看settings上面的配置没有问题的。你查看一下最近编辑的文件,退回至上个版本试试呢。可能是由于你对app中修改了或注释了某行代码导致的

Leave a Reply