ImageField isn't working

27 views
Skip to first unread message

Valéria Pacheco

unread,
Feb 19, 2015, 4:03:20 PM2/19/15
to django...@googlegroups.com
Hello! I'm a newbie in Django and Python, I'm trying to use the ImageField property.
The problem is represented in the attachment images.
The uploading of the image works fine, but when trying to access it, the link seems to be broken. 
I already checked for answers online but neither seems to work.

teste.bmp
teste2.bmp

Jorge Andrés Vergara Ebratt

unread,
Feb 19, 2015, 4:14:40 PM2/19/15
to django...@googlegroups.com
Hello Valéria,

That's Django's default, it doesn't handle media files by itself, if you are in development you can add this line to urls.py

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Don't forget you need to import static and settings:

from django.conf import settings
from django.conf.urls.static import static

That should work... For development only, in production use something like Nginx or Apache



--
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/8cf5041c-2ad7-40ec-9243-d4e1a928013e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lucas Klassmann

unread,
Feb 19, 2015, 4:15:15 PM2/19/15
to django...@googlegroups.com
Hi Valéria,

Try verify if that support for statics files is correctly configured.


Before read the documentation, check which version of your django is installed.

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 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/8cf5041c-2ad7-40ec-9243-d4e1a928013e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Lucas Klassmann
Desenvolvedor de Software

Email: lucaskl...@gmail.com
Web site: http://www.lucasklassmann.com

Tom Lockhart

unread,
Feb 19, 2015, 4:18:36 PM2/19/15
to django...@googlegroups.com
The URL you are trying seems to be /admin/backOffice/product/12/media/images/teste_processo.jpg/ which is not likely to work.

In my development server settings.py I’ve got the following:

MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, *MEDIA_URL.strip("/").split("/"))

and I’ve made a media/ directory inside my project area. Then you can find the image with a URL something like:

/media/images/teste_processo.jpg

(which may already be the case for you; look for the uploaded file and use a URL prefixed with “/media” then the path to the file).

hth

- Tom




--
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/8cf5041c-2ad7-40ec-9243-d4e1a928013e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<teste.bmp><teste2.bmp>


Valéria Pacheco

unread,
Feb 19, 2015, 5:00:11 PM2/19/15
to django...@googlegroups.com
Thank you very much!
it worked!
Both solutions combined.
I'm still trying to understand what happened but thank you!! :)

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/Px6Iqhl-ge8/unsubscribe.
To unsubscribe from this group and all its topics, 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.

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



--
Cumprimentos,
Valéria Pacheco

contacto móvel : 913473039



:)
Reply all
Reply to author
Forward
0 new messages