Closed jimmybutton closed 3 years ago
Hi @jimmybutton thanks for reaching out. I think the solution to your problem might be rather simple. You are using the MeasurementField
from models
not forms
. Of course a model field won't work in a form and vice versa. Small typo I guess, happens to the best of us ;) Let me know if you have any other questions. Best Joe
Hi @codingjoe many thanks, that solved it!
Maybe someone else will find this useful: It is also possible to define the unit_choices
on the Model
itself. They then get passed through when using a ModelForm
- great stuff!
Thanks for this project, it seems to be really useful! I've spend some time trying to get started with it. I managed to create a form and render it in a template like this:
I was trying to modify the units displayed in the dropdown like shown in the documentation:
However when playing with this form in the django shell, it seems there are no fields:
I tried different things, using
MeasurementWidget
or modifying the widget via the widget property in the Meta class in the ModelForm approach.Am I missing something here? Any advice welcome, thanks!
django = "~=3.1.0" django-measurement = "==3.2.3" python_version = "3.8"