无法执行 makemigrations 命令

unable to do makemigrations command

我会告诉大家我在这个错误发生之前所做的步骤

顺便说一句,我的超级用户=>id:myuser 电子邮件:pass:myuser

    hostname $ django-admin.py startproject myproj

    hostname $ cd myproj

    hostname $ python manage.py startapp myapp

    hostname $ python manage.py migrate

    hostname $ python manage.py createsuperuser

    hostname $ python manage.py runserver

    hostname $ pip install psycopg2

    hostname $ psql 

    postgres=# create role myuser with createdb superuser 
    login password 'myuser';

    postgres=# create database mydb with owner myuser;

    postgres=# exit

然后我编辑 myproj\settings.py,然后我 运行 命令 python manage.py makemigrations myapp 并发生以下错误

Traceback (most recent call last):
  File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\apps\registry.py", line 155, in get_app_config
    return self.app_configs[app_label]
KeyError: 'admin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv)

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 366, in execute
    self.check()

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 392, in check
    all_issues = self._run_checks(

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 382, in _run_checks
    return checks.run_checks(**kwargs)

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)

 File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 407, in check
    for pattern in self.url_patterns:

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module
    return import_module(self.urlconf_name)

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)

File "<frozen importlib._bootstrap>", line 1014, in _gcd_import

File "<frozen importlib._bootstrap>", line 991, in _find_and_load

File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked

File "<frozen importlib._bootstrap>", line 671, in _load_unlocked

 File "<frozen importlib._bootstrap_external>", line 783, in exec_module

File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

File "C:\myproj\myproj\urls.py", line 20, in <module>
    path('admin/', admin.site.urls),

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 224, in inner
    self._setup()

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\admin\sites.py", line 537, in _setup
    AdminSiteClass = import_string(apps.get_app_config('admin').default_site)

File "C:\Users\userpc\AppData\Local\Programs\Python\Python38\lib\site-packages\django\apps\registry.py", line 162, in get_app_config
    raise LookupError(message)

LookupError: No installed app with label 'admin'.

这是我唯一修改的文件

myproj/settings.py

import os

    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = 'zl@b!)%627#jp-sa40v&yscmvd8r#f^^vi(45z)sqg-c2=o*-e'

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

    ALLOWED_HOSTS = []


    # Application definition

    INSTALLED_APPS = [
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.staticfiles',
        # Third party apps
        'rest_framework',
        'rest_framework.authtoken',
        # Internal apps
        'myapp',
    ]

    MIDDLEWARE = [
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    ]

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


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

    DATABASES = {
        'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'mydb',
        'USER': 'myuser',
        'PASSWORD': 'myuser',
        'HOST': 'localhost',
        'PORT': '5432',
        }
    }


    # Password validation
    # https://docs.djangoproject.com/en/3.0/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',
        },
    ]

    LANGUAGE_CODE = 'en-us'

    TIME_ZONE = 'UTC'

    USE_I18N = True

    USE_L10N = True

    USE_TZ = True


    STATIC_URL = '/static/'

有什么我可以做的吗???我错过了什么吗???我正在尝试使用像 2.2.10 这样的旧版本的 django,但它仍然没有用,当这个错误发生时,我使用了新版本的 django 和 python 以及 postgresql

您的应用程序正在导入管理员,但 Django 管理员不存在于您的 settings.py。

INSTALLED_APPS中添加:

INSTALLED_APPS = [ 'django.contrib.admin',  'your.other.applications.follow']