-
Notifications
You must be signed in to change notification settings - Fork 13
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
Document how to use MDEWidget on a form #20
Comments
Did you ever manage to figure this out? I'm now struggling with the exact same thing! |
I did. Memory is not so fresh, so I just checked my codebase. It's set here: Which is a very particular solution. More generally it seems you need to import the widget:
then on a form field explicitly set it:
There may be a cleaner way, an easier way, I don't know. I find that a bit clunky and would like to think the widget could b specified sort of as a global option, say like when including Exploring other options on this repo I note of interest: https://github.com/dmptrluke/django-markdownfield/blob/master/markdownfield/forms.py and from this:
That setting the This issue stands. A clear explanation in the README on how to use it would be very useful and have saved my confusion, yours and this issue. |
Oh wow, that was a fast response! I was actually just about to reply "actually no worries I figured it out". Thanks though! I may end up looking into yours if I have to implement a required field at some point, since my solution glitched on that. I'll share my method in case it helps anyone else. Basically I after I posted my question I thought to re-check the original EasyMDE ReadMe just in case there was any workaround that wasn't too finicky with Django/Python. Turns out all I had to do in addition to the documentation already up on this project was some template modifications: 1. Add this to my form's template (uses the UNPKG CDN) as mentioned here:
2. Add a bit of JS to target the element as mentioned here:
And as mentioned, I then ran into this error and issue which occurred when creating a new post but not when updating an existing post. Fortunately the model field it corresponded to was allowed to have |
You can also use Django Forms for this: https://docs.djangoproject.com/en/4.2/topics/forms/media/ |
I've tried to document this now and tested it on a local project. Your comments are most welcome 👍 |
Nice! Thanks, everyone! |
Yeah, I figured there must be a django back-end way to do this. Thanks! |
Title says it all. Just isn't obvious, and I'm having to work it out as best possible. Be nice to have a little doc on it, or a mention in the README. Basically my forms are rendering with a standard TextArea it seems and I'm thinking I need to do something to get the MDEWidget in its place.
The text was updated successfully, but these errors were encountered: