Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented FieldsArrayField in models #663

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

2 participants