Hi,
not sure what I've done but I don't get the error anymore, instead I got
nothing. No error, no image in the preview and no image after the saving
and displaying the article.
To your questions, yes and yes. I can find the image in the server (under
static/media/django-summernote/<date-of-upload>), and I can find the image
in the DB.
Interestingly, while using the "load image from URL" option in the
summernote dialog, the url is inserted well, both in the preview and in the
displayed article (<img> tag with the url src in the right place in
form.cleaned_data['text']).
Evidently the problem exists only when uploading a local image. Which leads
me to the assumption that there is a problem with my media settings...
What I have is this:
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(PROJECT_PATH, "static", "media")
MEDIA_URL = "media/"
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT, 'show_indexes': True
}),
I can access the uploaded images via 'media/' and browsing through the
folders, so I thought it's set up well, no I'm not so sure.
Any idea what's going on here?
On Tuesday, June 2, 2015 at 6:44:53 AM UTC+3, James Schneider wrote:
>
> 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
>
>
>
> On Jun 1, 2015 6:56 PM, "hemulin" <[email protected] <javascript:>>
> wrote:
>
>> (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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> 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
>>
>> <https://groups.google.com/d/msgid/django-users/1d2c3458-2275-48c8-b9b8-bc9ccbcb5e57%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
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/de7c9520-c772-4b4b-9932-b5da56c621a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.