Re: Feature Request: New PostgreSQL ArrayField

2022-08-10 Thread Adrian Torres
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 
>  
> 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.


PivotTable or MDDataTable

2022-08-10 Thread Elias Coutinho
My friends good night.
Imagine Excel with a pivot table.
Can we build something with Kivy or KivyMD?

I could use MDDataTable but I think it doesn't allow something like that.

Do you have any minimalist examples?

-- 
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/742819af-c2eb-4d7b-b62e-c48a7c48f8dcn%40googlegroups.com.


Re: Feature Request: New PostgreSQL ArrayField

2022-08-10 Thread Jacob Rief
Hello Liamine,
Django offers a 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/45971297-a63f-4409-8ee0-357cbed31fe0n%40googlegroups.com.


Feature Request: New PostgreSQL ArrayField

2022-08-10 Thread Liamine Cheridi
Hello to all,

at Pricemoov we’re using Postgresql arrays (

https://www.postgresql.org/docs/15/arrays.html) to store prices of a given
product.

More precisely, a given product can have either:

- standard: N prices (1d array)

- calendar: D * N prices, when the client is setting up different
prices for each day of a given time window (2d array)

So far, we modelled both use cases using a single table queried through raw
SQL queries.

We’re currently trying to migrate the raw SQL queries to Django’s ORM,
using ArrayField-s.

As per what is written at

https://docs.djangoproject.com/en/4.1/ref/contrib/postgres/fields/#arrayfield,
in a given field of a table, we can either have:

- an ArrayField (1d), or

- an ArrayField(base_field=ArrayField(…) …) (2d)

but cannot have both.

Instead of having different fields or different tables (one for standard
and one for calendar use cases), we’re exploring the possibility of adding
a custom field ArrayOrMatrixField. To have a better description of that
idea, we pushed the PR https://github.com/django/django/pull/15943 (WIP,
please do not consider it as a version ready to be reviewed for merge)

Given that such a field is not available in Django yet, we think there may
be a reason for that. More precisely, we’d have the following questions:

- do you anticipate any feature incompatibility/logical bomb that
would be introduced by such a custom field?

- if not, would you be interested in integrating such a field in
Django?

Best regards,

Liamine Cheridi, Backend Engineer at Pricemoov

-- 
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/CABexJmYQD9Nq%2B14TrE0DiSx62iBFfGVToUnQnZ3PmJWFFoXXbQ%40mail.gmail.com.