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?