Skip to content

Conversation

NMagpie
Copy link

@NMagpie NMagpie commented Apr 17, 2023

The FieldsArrayField is a custom Django model field that allows you to create an array of fields inside a document. You can specify a base field when you create an instance of FieldsArrayField, and then use the resulting field like a regular Python list.

class Foo(models.Model):
    tags = FieldsArrayField(models.CharField(max_length=255), blank=True)

We can instanciate such model just using python list:

foo = Foo(
    tags=[ 'foo', 'bar', 'test' ]
)

@p-matt
Copy link

p-matt commented Oct 11, 2023

Not working as expected

from djongo import models
from geocoding_api.API.mixins import TimestampMixin

class Geocoding(TimestampMixin):
    searchAddresses = models.fields.FieldsArrayField(models.CharField(max_length=255))

Which give

ValueError('You must specify a base_field')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.