0

I am newbie of django user.I trying to learn django webframework. because of that I meet interesting error and I couldn't solve it. I want save image to sqlite.When I upload an image it's working but when I try to display the picture I meet an error. I tried other answers but its didn't work.I am waiting your help.Thank you

error
Request Method: GET
Request URL:         http://127.0.0.1:8000/admin/info/airimage/1/media/Ataturk_Havalimani_2.jpg/
airimage object with primary key u'1/media/Ataturk_Havalimani_2.jpg' does not exist.
You're seeing this error because you have DEBUG = True in your Django settings file.          Change that to False, and Django will display a standard 404 page.

my settings.py

import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


SECRET_KEY = 'amln51jyuo*wj2@g6k3vdd^@2)&84i#1@n2xvgx7hh#bpf7(l!'

DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = [] ....... 

urls.py

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()


urlpatterns = patterns('',
# Examples:
# url(r'^$', 'tav.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),

url(r'^admin/', include(admin.site.urls)),
)

and my content of folder

>tav
>info
 __init__.py
 admin.py
 models.py
 tests.py
 views.py
>media
>tav
 __init__.py
 settings.py
urls.py
wsgi.py
db.sqlite3
manage.py

model for airimage

class airimage(models.Model):
    stuff_image = models.FileField(upload_to="media/")
    airno=models.ForeignKey(airandoto)

    def __unicode__(Self):
        return self.airno
    class Meta: 
        verbose_name_plural="AirImage"
gmfreak
  • 399
  • 4
  • 12
hydrojan
  • 5
  • 4
  • Similar to https://stackoverflow.com/questions/14806289/django-error-page-not-found-404 which has better answers. – Jay M Jun 22 '17 at 10:23

1 Answers1

0

You're attempting to access the image incorrectly. Can you post the model for airimage? The primary key for the image in question looks to be 1, but you are appending extra information to the URL which is making Django think that you are looking for the row with the primary key of '1/media/Ataturk_Havalimani_2.jpg', which definitely does not exist.

Jeff N
  • 430
  • 3
  • 5