Hi Liamine,

I think there's various solutions you could try before going the custom 
field route:

* You could try just using the 2D version and use some sentinel value for 
the date (NULL?) to treat the case where you just want an array of N prices.
* You could try using django-polymorphic [1] which would allow you to 
define one "StandardPricingProduct" model and one "CalendarPricingProduct" 
model, and be able to query them together (e.g. get all products regardless 
of "type").
* You could try Jacob's suggestion.
* You could try creating a pricing model and have a FK between Pricing and 
Product -- I know you want to avoid this, but to me it sounds simpler and 
more maintainable than going the custom field route.

Cheers,
Adrian

[1] https://django-polymorphic.readthedocs.io/en/stable/

On Wednesday, August 10, 2022 at 6:44:55 PM UTC+2 jacob...@gmail.com wrote:

> Hello Liamine,
> Django offers a JSONField 
> <https://docs.djangoproject.com/en/4.1/ref/models/fields/#jsonfield> 
> which can be used to store an array.
> You can use it to store a list of prices. What's the benefit of using an 
> array instead of JSON?
> – Jacob
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/bbbfb68d-1167-45aa-bf8d-4f8b0346c411n%40googlegroups.com.

Reply via email to