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+unsubscribe@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.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment