django-jsonform
django-jsonform copied to clipboard
Is there a way to use this widget outside of admin site?
Is there a way to use this JSONForm Widget outside of Django Admin Site?
I want to use this widget in a custom view with template.
I've not tried it but since it's just a regular Django form field and widget, it should be possible to use it outside the admin.
Did you try it? What didn't work?
Hi, I tried, with a little fiddling with the crispy settings, I was able to use it outside django admin site. Currently to make the styles consistent, I am injecting classes and styles to the jsonformwidget dom nodes, but a better way to customize the style would be very appreciable.
Yes, theming support is definitely on my to-do list. But that won't be anytime soon.
I had initially created this just for using inside the admin and did not plan much for other use cases. So the html structure and class names are all a mess right now.
This would require rewriting significant portion of the UI generator.
Anyway, for frontend stuff, I'd recommend react-jsonschema-form. It supports theming (bootstrap, material etc) out of the box.
Hi what settings we need to change to use this ?
I've not tried it but since it's just a regular Django form field and widget, it should be possible to use it outside the admin.
Did you try it? What didn't work?
Hi I tried to use outside the admin page but its not showing the fileds values ?...
I have used like this {{ ml_settings.as_p }}
but its working fine in the Admin tool
Hi, I tried, with a little fiddling with the crispy settings, I was able to use it outside django admin site. Currently to make the styles consistent, I am injecting classes and styles to the jsonformwidget dom nodes, but a better way to customize the style would be very appreciable.
Hi Arpan, do you know which settings you add to get it worked outside admin tool. :) ?
I, too, would like to know how to use this outside of an Admin section of a site? Any tips out there?
I'm on python 3.12.1 and Django 5.
Try using {{ object.media }}. it worked for me.
Try using {{ object.media }}. it worked for me.
Ditto. The problem here is that if you try to use a ModelForm in an entirely custom template, the media won't be included (which is how the django-jsonform css/js gets in normally in the Django admin). You have to add {{ form.media }} to your head block yourself if using a custom template.