(noob warning)
I wanted to use summernote within a model but without using the default
modelForm.
I ended up mixing the two like this (can't have widgets on model field...):
In models I have
class Article(models.Model):
"""Represents a wiki article"""
title = models.CharField(max_length=100)
slug = models.SlugField(max_length=50, unique=True)
text = models.TextField()
author = models.ForeignKey(User)
created_on = models.DateTimeField(auto_now_add=True)
objects = models.Manager()
tags = TaggableManager(through=TaggedArticle)
class ArticleForm(forms.ModelForm):
class Meta:
model = Article
fields = ['text']
widgets = {
'text': SummernoteWidget(),
}
After having the right display while serving the template, I attempt to
save the Article like this:
in views, a part of the saving method:
form = ArticleForm(request.POST or None)
if form.is_valid():
#import pdb; pdb.set_trace()
article = Article()
article.text = form.cleaned_data['text'] # THIS IS MY HACKISH WAY OF
FETCHING THE CONTENT
article.author = request.user
article.title = request.POST['title']
article.save()
if request.POST.has_key('tags'): #add relevant ones
article_tags = request.POST.getlist('tags')
article_tags = [tag for tag in article_tags]
article.tags.add(*article_tags)
return HttpResponse("Article saved successfully")
1) I have everything configured (MEDIA_ROOT, MEDIA_URL, summernote url as
described in the setup)
2) The widget is displayed well within iframe
3) When uploading an image I get the "mime interpreted as text blah blah
blah" error
4) After saving, when displaying the article, the text is displayed well
with all the markup but no image is displayed
5) For every image I try to add to an article, the image appear in
django-summernote/<date-of-upload>/<some-hash-string>.<image-extension>
Finally, how would you suggest me to solve the problem and having the
images uploaded and displayed correctly in the resulted article text?
Cheers.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/1d2c3458-2275-48c8-b9b8-bc9ccbcb5e57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.