Hi.
You could create custom form field that makes conversions both ways.
ke 8. toukok. 2019 klo 1.25 Tim Bell kirjoitti:
> Hi,
>
> I have a model with an integer field storing a duration in hours, while I
> want to present that to users in a form in days. (The choice of these
> different units
One way could be make a custom read only field to show it in current value
in days and take a custom field and on save_model take its value as days
multiply it with 24 and save it in model's field.
On Wed, May 8, 2019, 7:05 AM Joe Reitman wrote:
> Hi Tim,
>
> There is a 'Best Practices' guide
Hi Tim,
There is a 'Best Practices' guide for Django that recommends making models
fat,
https://django-best-practices.readthedocs.io/en/latest/applications.html#models.
With that it would be logical to do both conversions in the model.
Regards,
Joe
On Tuesday, May 7, 2019 at 5:24:09 PM
Hi,
I have a model with an integer field storing a duration in hours, while I
want to present that to users in a form in days. (The choice of these
different units is imposed by other factors not under my control.)
So, when saving a form, I need to convert a value in days to hours by
4 matches
Mail list logo