简体   繁体   English

Django和PostgreSQL“未找到装置”

[英]Django and PostgreSQL “No Fixtures Found”

I've been trying to use PostrgeSQL with my Django apps but I get the following error before (right after starting the project when I only have the following files: __init__.py , manage.py , settings.pyc , urls.pyc , __init__.pyc , settings.py , urls.py ) and after I've added models: 我一直在尝试将PostgreSQL应用程序与PostrgeSQL一起使用,但是之前收到以下错误(在启动项目后,当我只有以下文件时: __init__.py urls.pyc __init__.pyc . urls.pycmanage.pysettings.pycurls.pyc__init__.pycsettings.pyurls.py )以及添加模型之后:

python manage.py syncdb
Creating tables ...
Installing custom SQL ...
Installing indexes ...
No fixtures found.

I'm not even trying to load fixtures. 我什至不尝试加载灯具。 Psycopg2 is installed. 已安装Psycopg2。 This is the database section of my settings.py 这是我的settings.py的数据库部分

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'myapp_development',                     
        # Or path to database file if using sqlite3.
        'USER': 'foo',                      # Not used with sqlite3.
        'PASSWORD': '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.
    }
}

This means that Django had not found any fixtures. 这意味着Django尚未找到任何装置。 This is a standard message if there are no fixtures. 如果没有固定装置,这是标准消息。

Fixture is a file of the next format (using to create real objects in a database by an existing model): 夹具是下一种格式的文件(用于通过现有模型在数据库中创建实际对象):

[
  {
    "model": "myapp.person",
    "pk": 1,
    "fields": {
      "first_name": "John",
      "last_name": "Lennon"
    }
  },
  {
    "model": "myapp.person",
    "pk": 2,
    "fields": {
      "first_name": "Paul",
      "last_name": "McCartney"
    }
  }
]

See more for details: http://docs.djangoproject.com/en/dev/howto/initial-data/ 详情请参阅: http : //docs.djangoproject.com/en/dev/howto/initial-data/

Did you set the FIXTURE_DIRS setting value in your settings.py ? 你设置FIXTURE_DIRS在设定值settings.py

See here for documentation. 有关文档,请参见此处

When you run 当你跑步

manage.py syncdb manage.py syncdb

django try to load initial data for apps in you project. django尝试为您项目中的应用程序加载初始数据。 By default that data loaded from app-dir\\fixtures\\initial_data.[xml/yaml/json] files So when file does not exist you see: 默认情况下,该数据是从app-dir \\ fixtures \\ initial_data。[xml / yaml / json]文件加载的,因此当文件不存在时,您会看到:

No fixtures found 找不到装置

Lean more on django official page : 在Django 官方页面上进一步学习

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

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