(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...):
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:
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.
Can you post the full error you're receiving? The 'blah blah blah' is probably the most important. A mention of MIME types likely means that the image is not uploading correctly. Can you actually find the image on the server? Or a record of it in the database?
-James
--
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 django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
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.
Have you validated that the URL being generated in the final HTML (the source HTML in the browser) is pointing to the right location? If not, I would tend to agree with your assertion that the media settings need tweaking.
-James
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/de7c9520-c772-4b4b-9932-b5da56c621a9%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/07d66382-4fc2-4a9a-928e-921eda5ca8fe%40googlegroups.com.