Using gizmos in django forms?

9 views
Skip to first unread message

speleo...@gmail.com

unread,
Jun 15, 2020, 4:56:45 AM6/15/20
to Tethys Platform
First off, kudos to creating this development platform. After spending some time learning Openlayers, Geoserver, POSTGIS, Docker, and then trying to figure out how to get them working together in a Node.js app, I finally discovered Tethys, where these pieces were largely already baked-in with a working configuration. Most of my programming is in Python, so Django has turned out to be much quicker for me to work with than Node.js. In short,  Tethys is saving me a lot of effort and time.  

One challenge I have run into is that the application I'm developing requires some relatively involved forms. I need a lot more control over form layout and widgets than I easily get with using the described approaches in the Tethys documentation. As a result, I have delved into using Django form objects, which are working well for me. However, I'm curious if there is some (perhaps hacky) way to include Tethys gizmos as a Django form field. For example, form field objects let you specify a widget. Can this somehow be used to hook into Tethys gizmos? Or perhaps is there a Tethys object than can be put in the place of a Django form field within a form class definition? 

Specifically, I was hoping to bring in the DatePicker(), as it looks like doing something similar directly with Bootstrap and Django is a bit of a pain. 

Thanks,
Matt

swainn

unread,
Jun 15, 2020, 10:05:13 AM6/15/20
to Tethys Platform
Matt:

Thanks for reaching out. I'm glad Tethys is helping you with your work.

Unfortunately, we haven't established a pattern for using Tethys Gizmos in Django forms. You would need to create a custom widget/form field that maps the correct parameters to the Gizmo, which can certainly be done. 

The good news is that we do have a development sponsor that is interested in developing better integration between gizmos and Django forms for Tethys, so that feature will be coming soon. It's probably a few months away at the soonest though.

Nathan


Rohit Khattar

unread,
Jun 15, 2020, 2:37:10 PM6/15/20
to Tethys Platform
Great suggestion. Hoping to see these in future Tethys Versions. 
Meanwhile, have you tried using type="date" in the input field? Google Chrome supports a datepicker by default and it might be a good solution to your specific issue for a short term. Here is a link with some more information: 

Matt Covington

unread,
Jun 15, 2020, 4:46:37 PM6/15/20
to Tethys Platform
Glad to hear that better integration with forms is in the works.

Thanks for the suggestion, Rohit. Indeed, if I set the type attribute
to date within my DateInput widget in the field definition of the form
object, then I get a reasonable datepicker. Not as slick as the
Bootstrap one, but much better than a plain text field.

Best,
Matt

-------------------------
Matt Covington
Associate Professor
Department of Geosciences
340 N. Campus Dr.
216 Gearhart Hall
University of Arkansas
Fayetteville, AR 72701

webpage - http://www.speleophysics.com/
-------------------------
> --
> You received this message because you are subscribed to a topic in the Google Groups "Tethys Platform" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/tethysplatform/RNVTkOMyIVc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to tethysplatfor...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/tethysplatform/e929d663-d57a-4920-96e8-f6c39dbeb05ao%40googlegroups.com.

Michael S

unread,
Jun 16, 2020, 11:31:17 AM6/16/20
to Tethys Platform
Matt, this would be a totally different approach, but since you say you need your forms to be "involved" maybe you want to take a look at Tethys Bokeh Integration functionality combined with Param and Panel. This allows you to create dynamic forms, graphs, datepickers, sliders, etc. that can served as events (on change) to other actions which can even include Python functions in the backend. Here is some of the documentation: http://docs.tethysplatform.org/en/stable/tutorials/bokeh.html?highlight=bokeh%20integration

I recommend looking into the Handler Functions Using Param and Panel section and this link for a working tutorial: http://docs.tethysplatform.org/en/stable/tutorials/bokeh.html 


Cheers,
Michael

On Monday, June 15, 2020 at 2:46:37 PM UTC-6, Matt Covington wrote:
Glad to hear that better integration with forms is in the works.

Thanks for the suggestion, Rohit. Indeed, if I set the type attribute
to date within my DateInput widget in the field definition of the form
object, then I get a reasonable datepicker. Not as slick as the
Bootstrap one, but much better than a plain text field.

Best,
Matt

-------------------------
Matt Covington
Associate Professor
Department of Geosciences
340 N. Campus Dr.
216 Gearhart Hall
University of Arkansas
Fayetteville, AR 72701

webpage - http://www.speleophysics.com/
-------------------------


On Mon, Jun 15, 2020 at 8:37 PM Rohit Khattar <onl...@gmail.com> wrote:
>
> Great suggestion. Hoping to see these in future Tethys Versions.
> Meanwhile, have you tried using type="date" in the input field? Google Chrome supports a datepicker by default and it might be a good solution to your specific issue for a short term. Here is a link with some more information:
>
> https://developers.google.com/web/updates/2012/08/Quick-FAQs-on-input-type-date-in-Google-Chrome
>
> - Rohit
>
> On Monday, June 15, 2020 at 2:56:45 AM UTC-6, speleo...@gmail.com wrote:
>>
>> First off, kudos to creating this development platform. After spending some time learning Openlayers, Geoserver, POSTGIS, Docker, and then trying to figure out how to get them working together in a Node.js app, I finally discovered Tethys, where these pieces were largely already baked-in with a working configuration. Most of my programming is in Python, so Django has turned out to be much quicker for me to work with than Node.js. In short,  Tethys is saving me a lot of effort and time.
>>
>> One challenge I have run into is that the application I'm developing requires some relatively involved forms. I need a lot more control over form layout and widgets than I easily get with using the described approaches in the Tethys documentation. As a result, I have delved into using Django form objects, which are working well for me. However, I'm curious if there is some (perhaps hacky) way to include Tethys gizmos as a Django form field. For example, form field objects let you specify a widget. Can this somehow be used to hook into Tethys gizmos? Or perhaps is there a Tethys object than can be put in the place of a Django form field within a form class definition?
>>
>> Specifically, I was hoping to bring in the DatePicker(), as it looks like doing something similar directly with Bootstrap and Django is a bit of a pain.
>>
>> Thanks,
>> Matt
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "Tethys Platform" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/tethysplatform/RNVTkOMyIVc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to tethysp...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages