6

I have the following error message:

AttributeError: 'module' object has no attribute 'ArrayField'

Here is the relevant code segment:

from __future__ import unicode_literals
from django.db import models
from django.contrib.postgres.fields import ArrayField

class TypeStatistics(models.Model):
    bots_array = models.ArrayField(models.CharField(max_length=50), blank=True)

Any idea what can be causing this?

1 Answer 1

18

Two things, first make sure that you are using Django version >= 1.8 then change the following line:

bots_array = models.ArrayField(models.CharField(max_length=50), blank=True)

to

bots_array = ArrayField(models.CharField(max_length=50), blank=True)

the django.db.models does not have an ArrayField but you have imported ArrayField from contrib postgresql so that's what you should be using.

Sign up to request clarification or add additional context in comments.

1 Comment

from django.contrib.postgres.fields import ArrayField

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.