Uploading mediafiles

71 views
Skip to first unread message

Egon.F...@gmx.de

unread,
Mar 31, 2014, 5:42:13 AM3/31/14
to django-...@googlegroups.com
Django 1.6.2, FeinCMS 1.9.3

settings:
MEDIA_URL = '/media/'

FEINCMS_THUMBNAIL_DIR = '_thumbs/'
FEINCMS_MEDIALIBRARY_UPLOAD_TO = 'media/medialibrary/%Y/%m/'

After uploading a mediafile the files are stored in
_thumbs/media/medialibrary/2014/03/

media/medialibrary/2014/03/

In the database is also stored

media/medialibrary/2014/03/


The thumbnail is referenced in the admin interface as
/media/_thumbs/media/medialibrary/2014/03/
so it could not be found.

The image is also wrong referenced as
"/media/media/medialibrary/2014/03/P1000851.JPG"

What are the correct settings?

Egon


Egon.F...@gmx.de

unread,
Apr 1, 2014, 5:43:32 AM4/1/14
to django-...@googlegroups.com
Again I ask what are the correct settings. Django looks up the mediafile and the thumbnails in the project directory but with these settings and with
MEDIA_ROOT = os.path.join(BASE_DIR,'media')
feinCMS/Django stores the files in the main directory

Can somebody help?

Egon

Martin J. Laubach

unread,
Apr 14, 2014, 9:28:28 AM4/14/14
to django-...@googlegroups.com
FEINCMS_MEDIALIBRARY_UPLOAD_TO = 'media/medialibrary/%Y/%m/'


  Is that intentional? Upload_tos are relative to the media directory, so I guess there is a media too many here.
 

Egon.F...@gmx.de

unread,
Apr 18, 2014, 4:04:07 PM4/18/14
to django-...@googlegroups.com
Martin,

I assume my question was not clear enough. I tried many variants but no
variant works satisfactorily. Now I have in my settings:

MEDIA_URL = '/media/'
FEINCMS_THUMBNAIL_DIR = '_thumbs/'
FEINCMS_MEDIALIBRARY_UPLOAD_TO = 'medialibrary/%Y/%m/'

The url entry is
    (r'^media/(?P<path>.*)$', 'django.views.static.serve', \
        {'document_root': os.path.join(os.path.dirname(__file__),
'media/')}),


If I upload an image then the image is stored in
<project>/media/medialibrary/yyyy/mm/
and the thumbnail is stored in
<project>7media/_thumbs/medialibrary/yyyy/mm/

What happens?
In the admin interface mediafiles the image is listed
(admin/medialibrary/mediafile/1/) but there is no preview. The
HTML-source is:
<tr class="row1"><td class="action-checkbox"><input class="action-select" name="_selected_action" type="checkbox" value="1" /></td><td>
                <a href="/media/medialibrary/2014/04/xyz.JPG" target="_blank">
                    <img src="/media/_thumbs/medialibrary/2014/04/xyz_v_thumb_100x100.JPG" alt="" />
                </a></td><th><a href="/admin/medialibrary/mediafile/1/">AntjeSchminkt_CIMG1507_v.JPG</a></th><td><input type="hidden" class="medialibrary_file_path" name="_media_path_1" value="medialibrary/2014/04/AntjeSchminkt_CIMG1507_v.JPG" id="_refkey_1" /> AntjeSchminkt_CIMG1507_v.JPG <br />Bild 150&times;113, 31,0 KB</td><td>2014-04-18</td></tr>
Now I insert the image into a page. The mediafiles are listed without a
preview. Then in the browser is no image shown but the HTML is
<div class="imageHaupt">
    <p class="mittig"><img src="/media/medialibrary/2014/04/xyz.JPG"  width="580" alt="" > </img> </p>
    <p class="caption"></p>
    
    <p class="description"></p>
</div>
(The template:
<div class="imageHaupt">
    <p class="mittig"><img src="{{ content.mediafile.file.url }}"
alt="{{ content.mediafile.translation.caption }}"/></p>
    <p class="caption">{{ content.mediafile.translation.caption }}</p>
    {% if content.mediafile.copyright %}<p class="copyright">Foto: {{
content.mediafile.copyright }}</p>{% endif %}
    <p class="description">{{ content.mediafile.translation.description
}}</p>
</div>
)

Now i copy the image and the thumbnail to
/<project>/<app>/media/medialibrary/2014/04/
resp.
/<project>/<app>/media/_thumbs/medialibrary/2014/04/
The the image is shown in the page and the thumbnail in the admin
interface as preview.

That is not satisfactory.

Setting?
Or bug in feincms?

Egon

Pablo Gomez

unread,
Sep 10, 2015, 3:01:55 PM9/10/15
to Django FeinCMS
Egon,
I'm having the same issue here.
Have you managed to resolve it?
Thanks

Matthias Kestenholz

unread,
Sep 10, 2015, 3:21:10 PM9/10/15
to FeinCMS
Hey,

Where is the settings file located? What is the current value of MEDIA_ROOT?

Thanks,
Matthias


--
You received this message because you are subscribed to the Google Groups "Django FeinCMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-feincm...@googlegroups.com.
To post to this group, send email to django-...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/django-feincms/8de496f5-ccd3-4c3a-a982-862d89f997f6%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Matthias Kestenholz
COO & Partner

FEINHEIT GmbH
Molkenstrasse 21
8004 Zürich
www.feinheit.ch

Pablo Gomez

unread,
Sep 10, 2015, 3:27:03 PM9/10/15
to Django FeinCMS
Hi Matthias,
My Settings file is on a folder called feincms_app.
At the same level, I have a folder cms (my current app).
I tried to set various values of MEDIA_ROOT to no avail, now it's just commented.
Thanks
Pablo

Matthias Kestenholz

unread,
Sep 10, 2015, 3:34:21 PM9/10/15
to FeinCMS
Hi,

That cannot be correct. The default value of MEDIA_ROOT is the empty string (which probably means that files are stored in the same folder as manage.py)

If you're using the same URL entry as Egon, you're serving mediafiles from feincms_app/media/ ; ./medialibrary (MEDIA_ROOT) and ./feincms_app/media/ will never be the same.

Try something like this (with a recent version of Django, `BASE_DIR` is defined as the folder where `manage.py` should reside in)

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

from django.views.static import serve
urlpatterns += [
    url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
]



Really, FeinCMS does nothing special with media paths -- as long as MEDIA_ROOT, MEDIA_URL and static file serving work together, FeinCMS will also work. If a simple FileField or ImageField on a simple Model works, FeinCMS will work.

Hope it helps,
Matthias




For more options, visit https://groups.google.com/d/optout.

Pablo Gomez

unread,
Sep 11, 2015, 8:54:45 AM9/11/15
to Django FeinCMS
Excellent Matthias!
That did the trick.
Thanks a lot.
Pablo

Matthias Kestenholz

unread,
Sep 11, 2015, 10:30:46 AM9/11/15
to FeinCMS
On Fri, Sep 11, 2015 at 2:54 PM, Pablo Gomez <pablo...@gmail.com> wrote:
Excellent Matthias!
That did the trick.
Thanks a lot.
Pablo


Good to hear.

Thanks,
Matthias


Reply all
Reply to author
Forward
0 new messages