1

I'm trying to include a TinyMCE rich text field on one of my pages, using the library django-tinymce. I've got the following form set up:

class AddFactForm(forms.ModelForm):
    content = forms.CharField(widget=TinyMCE(attrs={'cols':80, 'rows':30}))

    class Meta:
        model = Fact

...and the model going with it looks like this:

class Fact(models.Model):
    submitted_by = models.ForeignKey(User, unique=False)
    content = tinymce_models.HTMLField()
    date_submitted = models.DateTimeField(auto_now_add=True)

I then have a view that looks like this:

def add_fact(request, sample_id):
    if request.method == "POST":
        form = AddFactForm(request.POST)
        if form.is_valid():
            print "Valid form!"
            return HttpResponseRedirect('/done/')
    else:
        form = AddFactForm()
        print "Form:"
        print form

        return render_to_response('add_fact.html',
                {
                    'form': form,
                },
                context_instance=RequestContext(request))

The print form statement was added by me for debugging. The problem I am having is that, in this case, the word Form: will be printed to the console, then the server will just hang, and the browser will eventually display a server timeout (I then have to kill the server process and restart it to get back to normal). When I don't have print form in there but have {{ form.as_ul }} in the template, the server still hangs. If I have neither (just pass the form to the template but never call as_ul on it in the template) then the page loads fine. What's wrong with this form?

benwad
  • 6,414
  • 10
  • 59
  • 93
  • are you using https://github.com/aljosa/django-tinymce ? – Anentropic Jan 10 '14 at 20:54
  • specifying `CharField` in the form won't make much difference as the `tinymce_models.HTMLField` still causes it to use the `TinyMCE` widget to render – Anentropic Jan 10 '14 at 20:59
  • @Anentropic yes, although I installed it via pip rather than cloning the source so I've got the latest pip version (1.5.2). – benwad Jan 13 '14 at 11:24
  • Also - if it's the case that the TinyMCE widget is rendering I'll change the wording of the question to refer to TinyMCE. Thanks for the heads up! – benwad Jan 13 '14 at 11:25

0 Answers0