Use the url it gives you inside src attribute inside img tag. On 30/07/2014 1:19 pm, "ngangsia akumbo" <ngang...@gmail.com> wrote:
> i have the following > > MODEL > > from django.db import models > > class Timer(models.Model): > title = models.CharField(max_length=100) > slug = models.SlugField(unique=True) > image2 = models.ImageField(upload_to='image2/') > last_seen = models.IntegerField() > > def __unicode__(self): > return self.title > > > URLS > from django.conf.urls import patterns, include, url > > > from django.contrib import admin > admin.autodiscover() > > urlpatterns = patterns('', > url(r'^testp/', include('testp.urls')), > > url(r'^admin/', include(admin.site.urls)), > ) > > TESTP/URLS > > from django.conf.urls import patterns, url > > from django.conf import settings > from django.conf.urls.static import static > > > from testp import views > > urlpatterns = patterns('', > # ex: /testp/ > url(r'^$', views.timers, name='timers'), > # ex: /test/5/ > url(r'^(?P<testp_id>\d+)/$', views.timers_detail, > name='timers_detail'), > )+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) > > > SETTING > # Example: "/home/media/media.lawrence.com/media/" > MEDIA_ROOT = > 'C:/Python27/Scripts/mysite0/Django-1.5/djang/bin/test0/image2/' > > # URL that handles the media served from MEDIA_ROOT. Make sure to use a > # trailing slash. > # Examples: "http://media.lawrence.com/media/", "http://example.com/media/ > " > MEDIA_URL = '/media/' > > # Absolute path to the directory static files should be collected to. > # Don't put anything in this directory yourself; store your static files > # in apps' "static/" subdirectories and in STATICFILES_DIRS. > # Example: "/home/media/media.lawrence.com/static/" > STATIC_ROOT = > 'C:/Python27/Scripts/mysite0/Django-1.5/djang/bin/test0/image2/static/' > > # URL prefix for static files. > # Example: "http://media.lawrence.com/static/" > STATIC_URL = '/static/' > > # Additional locations of static files > STATICFILES_DIRS = ( > 'C:/Python27/Scripts/mysite0/Django-1.5/djang/bin/test0/static/' > > TEMPLATE > > {{ tis.image2.url}} > > WHEN I DISPLAY THE IMAGE IT GIVE ME THE LINK INSTEAD ON THE BROWSER > > /media/image2/Desert.jpg > > WHERE AM I WRONG > > Am using django 1.5 > > -- > 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+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@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/1f016aef-903b-49f0-9641-c1b0bce98fa6%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/1f016aef-903b-49f0-9641-c1b0bce98fa6%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 django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@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/CAHqTbjnTz1wKLAWOiTHtoVDzzv4CnjRShLuaq6PEWyakMAhivQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.