简体   繁体   English

Django无法找到已安装的应用

[英]Django Can't Find Installed App

I have my directory structure like this for my Django application: 我的Django应用程序具有这样的目录结构:

project
    __init__.py
    settings.py
    ...
users
    __init__.py
    model.py
    ....

In my model.py I have this class: 在我的model.py中,我有这个课:

class User():
    ...

However when I configure my INSTALLED_APPS like this: 但是,当我像这样配置我的INSTALLED_APPS时:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'south',
    'users'
    # Uncomment the next line to enable the admin:
    # 'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
)

Django cannot find the application users. Django无法找到应用程序用户。 What am I doing wrong? 我究竟做错了什么?

Change model.py to models.py , or if you want to use a different name for your module append the app_label argument to your models Meta classes: model.py更改为models.py ,或者如果您想为模块使用其他名称,请将app_label参数附加到模型元类中:

class YourModel(models.Model):
    # fields...

    class Meta:
        app_label = 'users'

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

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