Python Django管理站点未显示模型的默认权限

Python Django管理站点未显示模型的默认权限,python,django,Python,Django,我的Django管理站点不显示任何模型的任何默认权限。实际上,我检查了数据库,在auth\u permissions表中找不到任何模型权限 我已经运行了python manage.py makemigrations和python manage.py migrate。我还尝试删除数据库和迁移文件,并再次运行上面的两个命令,但都不起作用。我已经在admin.py中注册了我的模型 我还可以尝试其他解决方案吗 管理员 from django.contrib import admin from .Mode

我的Django管理站点不显示任何模型的任何默认权限。实际上,我检查了数据库,在
auth\u permissions
表中找不到任何模型权限

我已经运行了
python manage.py makemigrations
python manage.py migrate
。我还尝试删除数据库和迁移文件,并再次运行上面的两个命令,但都不起作用。我已经在admin.py中注册了我的模型

我还可以尝试其他解决方案吗

管理员

from django.contrib import admin
from .Models import *


# Register your models here.

admin.site.register(LeaveRequest)
admin.site.register(Worker)
admin.site.register(TimeSheet)
设置.py

"""
Django settings for WorkTime project.

Generated by 'django-admin startproject' using Django 3.1.3.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

from pathlib import Path
import os
import rest_framework
import dj_database_url

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


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

# SECURITY WARNING: keep the secret key used in production secret!
# SECRET_KEY = '0yz04(%a^xuilqa8*@e^e)bj+n%&+jou=tg$%lb&#ox!lk1!x5'
SECRET_KEY = os.environ.get(
    'SECRET_KEY', '0yz04(%a^xuilqa8*@e^e)bj+n%&+jou=tg$%lb&#ox!lk1!x5')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DEBUG', '') != 'False'

ALLOWED_HOSTS = ['worktime-management.herokuapp.com', '127.0.0.1']


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'api',
    'rest_framework.authtoken',
    'crispy_forms',
    'web',
]

MIDDLEWARE = [
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'WorkTime.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        '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 = 'WorkTime.wsgi.application'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}


# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/3.1/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/3.1/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATIC_DIR = os.path.join(BASE_DIR,'static')
STATICFILES_DIRS = [
    STATIC_DIR,
]

# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

# Heroku: Update database configuration from $DATABASE_URL.
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)

# Media root
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

# Email config
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = os.environ.get('MAIL_PASSWORD')
EMAIL_HOST_USER = os.environ.get('MAIL_USERNAME')
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

# CSRF enable
CSRF_COOKIE_SECURE = True

# Rest Auth
REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.TokenAuthentication',
    ]
}

# Boostrap4
CRISPY_TEMPLATE_PACK = 'bootstrap4'

AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.AllowAllUsersModelBackend', )

在您的
admin.py
中,您正在将所有模型作为
从.Model import*
导入。如果您没有将
models.py
文件作为
models.py
进行操作,Python是一种区分大小写的编程语言


我想,
from.models import*
会起作用

上述解决方案解决了这个问题。然而,我的
模型
实际上是一个文件夹,我一直在尝试将模型划分为不同的文件,这些文件存储在该文件夹中。因此,对于那些有相同想法的人,只需将文件夹名称更改为
模型即可:v

谁说Django Admin应该显示您或任何其他模型的“默认权限”?什么是默认权限?我是否误解了此链接中的任何内容?如果默认权限未在django管理站点中显示为默认权限,那么如何使它们显示在管理站点中。auth_权限表没有任何默认权限。是的,可以!非常感谢你。尽管如此,我的
模型实际上是一个文件夹。我一直在尝试将模型划分到这个文件夹中的不同文件中,哈哈。