django-dynamic-models
django-dynamic-models copied to clipboard
Array Field is not supported
Requesting feature to support type ArrayField to allow the user to store data in an array.
@rvinzent Kindly think about this and let me know if this can be achieved. I'll try to help if possible
@yvsssantosh apologies for the delayed response. This sounds like a nice addition to the project :smile: . It should come with some checking to make sure array fields are supported by the database.
I think best way to implement this without building a complex logic to check whether database supports array fields or not will be to do it the way Django does.
- Firstly, the
data_type
argument should accept a special class_object something like
from dynamic_models import fields as dynamic_fields
color_field_schema = FieldSchema.objects.create(name='color', data_type=dynamic_fields.CharField(max_length=200)')
- Then, make a module specific to supported databases and put the ArrayField class there. Django example would be
from django.contrib.postgres.fields import ArrayField
from dynamic_models.postgres.fields import ArrayField
This way, it's explicit and devs can make their own decision.
I know it's already implemented and will be release in 0.2.0 but I just wanted to give my suggestion.
Thanks for this lib
@arpitremarkable
I know it's already implemented and will be release in 0.2.0
Where can you see that it is already implemented and that there is a version 0.2.0?
@dankgen-tobias I assumed it's done since author claimed somewhere that 0.2.0 will be released soon. And this is marked 0.2.0 candidate.
@arpitremarkable @dankgen-tobias 0.2.0
was released today and this feature unfortunately did not make it in. 0.2.0
is a big change to the API, but I wanted to limit the addition of new features in order to not delay the release any further.
Increased data type support is absolutely on the radar, and PRs are always appreciated!
- Firstly, the
data_type
argument should accept a special class_object something likefrom dynamic_models import fields as dynamic_fields color_field_schema = FieldSchema.objects.create(name='color', data_type=dynamic_fields.CharField(max_length=200)')
@arpitremarkable
The challenge with accepting Field
instances as arguments is it's not entirely clear how to store that information in the database so it can be reconstructed later. It could be something like classname
and kwargs
fields, but kwargs
would have to only contain serializable data types for values.
I like the idea though and it should be possible to implement and allow a lot more flexibility to the kinds of fields that can be used.