Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ArrayField missing 1 required positional argument

Tags:

python

django

I have imported the following header file

from django.contrib.postgres.fields import ArrayField

Used the following in the model

question_array = ArrayField(models.IntegerField, blank=True,)

i get the following error

Traceback (most recent call last)
  File "C:\Program Files (x86)\Python\Python35-32\lib\site-packages\django-1.10.4-py3.5.egg\django\__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Program Files (x86)\Python\Python35-32\lib\site-packages\django-1.10.4-py3.5.egg\django\apps\registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "C:\Program Files (x86)\Python\Python35-32\lib\site-packages\django-1.10.4-py3.5.egg\django\apps\config.py", line 199, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Program Files (x86)\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "C:\Users\DELL\Desktop\cstrom\comp\models.py", line 24, in <module>
    class User(models.Model):
  File "C:\Program Files (x86)\Python\Python35-32\lib\site-packages\django-1.10.4-py3.5.egg\django\db\models\base.py", line 157, in __new__
    new_class.add_to_class(obj_name, obj)
  File "C:\Program Files (x86)\Python\Python35-32\lib\site-packages\django-1.10.4-py3.5.egg\django\db\models\base.py", line 316, in add_to_class
    value.contribute_to_class(cls, name)
  File "C:\Program Files (x86)\Python\Python35-32\lib\site-packages\django-1.10.4-py3.5.egg\django\db\models\fields\__init__.py", line 689, in contribute_to_class
    self.set_attributes_from_name(name)
  File "C:\Program Files (x86)\Python\Python35-32\lib\site-packages\django-1.10.4-py3.5.egg\django\contrib\postgres\fields\array.py", line 75, in set_attributes_from_name
    self.base_field.set_attributes_from_name(name)
TypeError: set_attributes_from_name() missing 1 required positional argument: 'name'
like image 511
Sniper Avatar asked Dec 16 '16 09:12

Sniper


1 Answers

As per the docs

You still need to fully define the field inside the array field

question_array = ArrayField(models.IntegerField(null=True, blank=True), blank=True,)
like image 57
Sayse Avatar answered Oct 20 '22 08:10

Sayse