django - Form stopped saving to database after TextField was changed to HTMLField -


i had working input form model, included textfield called 'opis'. instances of model saved database. however, wanted give users more options when writing -- , storing -- particular bit of text. installed tinymce, changed textfield htmlfield , discovered this, putting

<head> {{ form.media }} </head>  

at beginning of template enough input field rendered tinymce widget. is, kept old modelform, , displayed changed, thought nice , convenient. however, when user submits form, nothing happens -- seems form valid, database not updated.

in models.py:

from tinymce.models import htmlfield  class kurs(models.model):    [skipping...]    opis = htmlfield()    [skipping rest] 

in forms.py:

class kursform(modelform):     class meta:         model = kurs         fields = "__all__"       

in views.py:

def createcourse(request):     if request.method=='post':         form = kursform(request.post)         if form.is_valid():             form.save()             return httpresponseredirect('/polls/usersite')     else:         form = kursform()      return render(request, 'polls/createcourse.html', {"form" : form}) 

and in createcourse.html:

<head>{{ form.media }}</head>  <form action="" method="post"> {% csrf_token %} {{ form }} <input type="submit" value="submit" /> </form> 

clicking 'submit' results in no observable effect. worked until changed textfield htmlfield. doing wrong?

edit: seems there similar issue raised tinymce, want report in case editing form in forms.py to

class kursform(modelform):     opis = forms.charfield(widget=tinymce(attrs={'required': false, 'cols': 30, 'rows': 10}))     class meta:         model = kurs         fields = "__all__"       

didn't help.

alright, turns out indeed issue tinymce. claudep kind enough me in this thread. sum up, have , doing job following:

-- subclassing widget:

class tinymcewidget(tinymce):     def use_required_attribute(self, *args):         return false 

-- having modified form follows (i guess might optional):

class kursform(modelform):     opis = forms.charfield(widget=tinymcewidget(attrs={'required': false, 'cols': 30, 'rows': 10}))     class meta:         model = kurs     fields = "__all__" 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -