please solve my problem

Discussion in 'Python' started by Divya Thakur, Jan 13, 2013.

  1. Divya Thakur

    Divya Thakur Guest

    hello i need help for my ecommerce project ,and here i am facing some problem here is my

    query
    "i want to show image by the help of MEDIA_URL and this is my template file code for this
    <img src="{{ MEDIA_URL }}images/products/thumbnails/{{ p.image }}" but it is not working

    and showing following error"

    raise TemplateDoesNotExist(name)
    TemplateDoesNotExist: 500.html
    [14/Jan/2013 01:08:11] "GET /static/images/products/thumbnails/12345 HTTP/1.1" 500 59

    but when i am going to use this link <img src="{{ MEDIA_URL }}

    images/products/thumbnails/rakesh.jpg >" although it is showing image but not showing

    anything else ahed of
    that link ,so i am unable to undersatnd that why this is happening although i know that

    all other things are right ,but it showing error in the template file

    here is my settings.py file

    # Django settings for ecomstore project.
    import os
    #import sys
    #hack to accommodate windows
    CURRENT_PATH = os.path.abspath(os.path.dirname(__file__).decode('utf-8')).replace('\

    \','/')

    DEBUG = False
    TEMPLATE_DEBUG = DEBUG

    ADMINS = (
    ('rakeshsingh', ''),
    )

    MANAGERS = ADMINS

    DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql',

    'sqlite3' or 'oracle'.
    'NAME': 'ecomstore', # Or path to database file if using

    sqlite3.
    'USER': 'rakeshsingh', # Not used with sqlite3.
    'PASSWORD': 'password', # Not used with sqlite3.
    'HOST': '', # Set to empty string for localhost. Not used

    with sqlite3.
    'PORT': '', # Set to empty string for default. Not used with

    sqlite3.
    }
    }

    # Local time zone for this installation. Choices can be found here:
    # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
    # although not all choices may be available on all operating systems.
    # In a Windows environment this must be set to your system time zone.
    TIME_ZONE = 'America/Chicago'

    # Language code for this installation. All choices can be found here:
    # http://www.i18nguy.com/unicode/language-identifiers.html
    LANGUAGE_CODE = 'en-us'

    SITE_ID = 1

    # If you set this to False, Django will make some optimizations so as not
    # to load the internationalization machinery.
    USE_I18N = True

    # If you set this to False, Django will not format dates, numbers and
    # calendars according to the current locale.
    USE_L10N = True

    # If you set this to False, Django will not use timezone-aware datetimes.
    USE_TZ = True

    # Absolute filesystem path to the directory that will hold user-uploaded files.
    # Example: "/home/media/media.lawrence.com/media/"
    #MEDIA_ROOT = "C:/Users/rakesh/Desktop/ecomstore/static/"
    MEDIA_ROOT = ''

    # 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 = '/static/'
    #MEDIA_URL = "http://localhost:8000/static/"

    # 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 = ''

    # URL prefix for static files.
    # Example: "http://media.lawrence.com/static/"
    STATIC_URL = '/static/'

    # Additional locations of static files
    STATICFILES_DIRS = (
    #"C:Users/rakesh/Desktop/ecomstore/static/"
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    )

    # List of finder classes that know how to find static files in
    # various locations.
    STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
    )

    # Make this unique, and don't share it with anybody.
    SECRET_KEY = '2h(8t+9z4z-m(fuhl17eqp78q!yxo4&amp;i54jofml3uoyv@a3y3x'

    # List of callables that know how to import templates from various sources.
    TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    # 'django.template.loaders.eggs.Loader',
    )

    MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    #'djangodblog.DBLogMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
    )

    ROOT_URLCONF = 'ecomstore.urls'

    # Python dotted path to the WSGI application used by Django's runserver.
    WSGI_APPLICATION = 'ecomstore.wsgi.application'

    TEMPLATE_DIRS = (
    os.path.join(CURRENT_PATH,'templates'),
    "C:/Users/rakesh/Desktop/ecomstore/templates/",
    #"C:/Python27/Lib/site-packages/django/contrib/admin/templates/admin",
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    )

    INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'catalog',
    #'djangodblog',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    'django.contrib.admindocs',
    'preview',
    'utils',
    )

    # A sample logging configuration. The only tangible logging
    # performed by this configuration is to send an email to
    # the site admins on every HTTP 500 error when DEBUG=False.
    # See http://docs.djangoproject.com/en/dev/topics/logging for
    # more details on how to customize your logging configuration.
    LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
    'require_debug_false': {
    '()': 'django.utils.log.RequireDebugFalse'
    }
    },
    'handlers': {
    'mail_admins': {
    'level': 'ERROR',
    'filters': ['require_debug_false'],
    'class': 'django.utils.log.AdminEmailHandler'
    }
    },
    'loggers': {
    'django.request': {
    'handlers': ['mail_admins'],
    'level': 'ERROR',
    'propagate': True,
    },
    }
    }
    SITE_NAME = 'Modern Shoppers'
    META_KEYWORDS = 'Electronics,footwera,clothing,book'
    META_DESCRIPTION = 'Modern Shoppers is an online supplier of electronics,footwear, and

    other accessories for people who want a different things'


    TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'django.core.context_processors.tz',
    'django.core.context_processors.request',
    'django.contrib.messages.context_processors.messages',
    'utils.context_processors.ecomstore',
    )

    here is my catalog.html file

    {% extends "base.html" %}
    {% block site_wrapper %}
    <div id="main">
    <a href="#content" class="skip_link">skip to main content</a>
    <div id="banner">
    <div class="bannerIEPadder">
    <div class="cart_box">
    [link to cart here]
    </div>
    Modern Shoppers
    </div>
    </div>
    <div id="navigation">
    <div class="navIEPadder">
    {% include "tags/navigation.html" %}
    </div>
    </div>
    <div id="middle">
    <div id="sidebar">
    <div class="sidebarIEPadder">
    [search box here]
    <br/>
    {% include "tags/category_list.html" %}
    </div>
    </div>
    <div id="content">
    <a name="content"></a>
    <div class="contentIEPadder">
    {% block content %}{% endblock %}
    </div>
    </div>
    </div>
    <div id="footer">
    <div class="footerIEPadder">
    [footer here]
    </div>
    </div>
    </div>
    {% endblock %}

    and this is my category .html file

    {% extends "catalog.html" %}
    {% block content %}
    <h1>{{ c.name }}</h1>
    {{ c.description }}
    </br></br>
    {% for p in products %}
    <div class="product_thumbnail">
    <a href="{{ p.get_absolute_url }}">
    <img src="{{ MEDIA_URL }}images/products/thumbnails/{{

    p.image }}"

    alt="{{ p.name }}"

    class="bn"/>
    </br>
    {{ p.name }}
    </a>
    </div>
    {% endfor %}
    {% endblock %}






    and this is my product.html file


    {% extends "catalog.html" %}

    {% block content %}
    <div class="product_image">
    <img src="{{ MEDIA_URL }}images/products/main/{{ p.image }}" alt="{{

    p.name }}"/>
    </div>
    <h1>{{ p.name }}</h1>
    Brand: <em>{{ p.brand }}</em>
    <br/><br/>
    SKU: {{ p.sku }}
    <br/>
    In categor{{ categories.count|pluralize:"y,ies" }}:
    {% for c in categories %}
    <a href="{{ c.get_absolute_url }}">{{ c.name }}</a>
    {% if not forloop.last %},{% endif %}
    {% endfor %}
    <br/><br/>
    {% if p.sale_price %}
    Was: <del> $ {{ p.old_price }} </del>
    <br/>
    Now: $ {{ p.price }}
    {% else %}
    Price: $ {{ p.price }}
    {% endif %}
    <br/><br/>
    [add to cart button]
    <br/><br/>
    <div class="cb"><br/><br/></div>
    <h3>Product Description</h3>
    {{ p.description }}
    {% endblock %}


    so please help me and fix that problem for me although i know that the error in template

    file but i could,t able to fix it
    Divya Thakur, Jan 13, 2013
    #1
    1. Advertising

  2. Divya Thakur

    Roy Smith Guest

    In article <>,
    Divya Thakur <> wrote:

    > "i want to show image by the help of MEDIA_URL and this is my template file
    > code for this
    > <img src="{{ MEDIA_URL }}images/products/thumbnails/{{ p.image }}" but it is
    > not working



    This is a django-specific question. You would do better to ask on the
    django-users mailing list:

    https://groups.google.com/forum/?fromgroups#!forum/django-users
    Roy Smith, Jan 13, 2013
    #2
    1. Advertising

  3. On Mon, Jan 14, 2013 at 7:35 AM, Divya Thakur
    <> wrote:
    > raise TemplateDoesNotExist(name)
    > TemplateDoesNotExist: 500.html
    > [14/Jan/2013 01:08:11] "GET /static/images/products/thumbnails/12345 HTTP/1.1" 500 59


    This sounds like a Django-specific issue. You'll probably get better
    results from a more Django-specific list:

    https://www.djangoproject.com/community/

    > here is my settings.py file
    > # Make this unique, and don't share it with anybody.
    > SECRET_KEY = '2h(8t+9z4z-m(fuhl17eqp78q!yxo4&amp;i54jofml3uoyv@a3y3x'


    You've just dumped a huge amount of text to us, including something
    that probably shouldn't have been shared. I strongly recommend you
    change this key, now that it's gone public, and consider trimming your
    text down to just what's needed to reproduce the problem.

    ChrisA
    Chris Angelico, Jan 13, 2013
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KK
    Replies:
    2
    Views:
    498
    Big Brian
    Oct 14, 2003
  2. Andrej Hocevar
    Replies:
    1
    Views:
    470
    Nick Austin
    Aug 18, 2003
  3. Simon
    Replies:
    2
    Views:
    384
    red floyd
    Jan 29, 2007
  4. Replies:
    4
    Views:
    302
    osmium
    May 22, 2007
  5. crazzybugger
    Replies:
    0
    Views:
    292
    crazzybugger
    Oct 8, 2007
Loading...

Share This Page