SOLVED 目前我正在开展我的第一个django项目 . DB正在建模Abaqus输入文件的结构 . 这是守则

from django.db import models as m
import django.contrib.postgres as pg

class node(m.Model):
    inputfile = m.CharField(max_length = 255)
    source_id = m.IntegerField()
    source_sim = m.CharField(max_length = 255)
    coordinates = pg.fields.ArrayField(m.FloatField(), size = 3)

当我调用 manage.py makemigrations (或者只是python)时,它会给我错误消息:

AttributeError: module 'django.contrib.postgres' has no attribute 'fields'

当我在testscript中导入ArrayField时,它可以工作:

from django.contrib.postgres.fields import ArrayField
from django.db import models as m

a = ArrayField(m.FloatField(), size=3)
print(a)

>>><django.contrib.postgres.fields.array.ArrayField>

我能够在没有ArrayField的情况下将我的类迁移到TestDB中 . 我的Python版本3.7.1,我的Django版本是2.1.3

我的错是什么?

编辑:样式和格式 . 感谢您的建议 . 编辑:已解决,但无法找到如何标记