Python和Django无法运行[Python manage.py sql应用程序]

Python和Django无法运行[Python manage.py sql应用程序],python,django,django-models,python-3.x,django-admin,Python,Django,Django Models,Python 3.x,Django Admin,有人知道可能是什么问题吗?多谢各位 [更新] *强文本*管理者=管理员 python manage.py sql polls Sqlite3需要数据库文件的完整路径。确保数据库名称不是相对路径 应该是这样的: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.

有人知道可能是什么问题吗?多谢各位

[更新] *强文本*管理者=管理员

python manage.py sql polls

Sqlite3需要数据库文件的完整路径。确保数据库名称不是相对路径

应该是这样的:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'E:\Python\mysite\sqlitedb', # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}



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

还要确保该文件没有太严格的权限。

使用您的
settings.py
文件更新问题。这比我要写的要好。编辑以添加导入行谢谢Yuval我按照教程创建了一个模型文件并运行了
python manage.py sql polls
,我想这将为我创建db文件。所以我不需要指定db文件的路径
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'E:\Python\mysite\sqlitedb', # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}



INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    # 'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'polls',
)
import os
PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__))
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite',
        'NAME': os.path.join(PROJECT_ROOT, 'dev.db'),
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}