Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to use this widget outside of admin site? #95

Open
arpanpreneur opened this issue Mar 21, 2023 · 9 comments
Open

Is there a way to use this widget outside of admin site? #95

arpanpreneur opened this issue Mar 21, 2023 · 9 comments
Labels
enhancement New feature or request
Milestone

Comments

@arpanpreneur
Copy link

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.

@bhch
Copy link
Owner

bhch commented Mar 21, 2023

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?

@arpanpreneur
Copy link
Author

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.

@bhch
Copy link
Owner

bhch commented Mar 25, 2023

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.

@bhch bhch added this to the v3.0.0 milestone Apr 7, 2023
@bhch bhch added the enhancement New feature or request label Apr 7, 2023
@pritamfocal
Copy link

Hi what settings we need to change to use this ?

@pritamfocal
Copy link

pritamfocal commented Apr 17, 2023

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

@pritamfocal
Copy link

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. :) ?

@nathan-gilbert
Copy link

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.

@pritamfocal
Copy link

Try using {{ object.media }}. it worked for me.

@calebsyring
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants