mercredi 15 avril 2015

Get 404 error when upload file to django admin

I want to attach pictures in my application django 1.8. When I attach a file, I have a link to it in the admin panel. After I click on the link I get error code 404.


My url: http://ift.tt/1EF8H8o


My settings



"""
Django settings for website project.

Generated by 'django-admin startproject' using Django 1.8.

For more information on this file, see
http://ift.tt/1CMZftV

For the full list of settings and their values, see
http://ift.tt/1EF8H8q
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

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

# Quick-start development settings - unsuitable for production
# See http://ift.tt/1CMZfK9

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '6tmda(mjlwf%kl1*r@=6s0*#ozpvu&89@hlkcj9r2+(euk4kq#'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
'suit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
'www',
'tinymce',
'crispy_forms',
'bootstrap_pagination',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'website.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.request",
)

WSGI_APPLICATION = 'website.wsgi.application'


# Database
# http://ift.tt/1EF8GkO

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Internationalization
# http://ift.tt/1CMZi8Y

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# http://ift.tt/1EF8GkR

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, 'public_assets')

STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'


My model



class Paint(models.Model):
AVAILABLE = "Available"
NOT_AVAILABLE = "Not available"
STATUS_PAINT = (
(AVAILABLE, "Available"),
(NOT_AVAILABLE, "Not available")
)
title = models.CharField(max_length=200)
gallery = models.OneToOneField(Gallery)
paint = models.ImageField(upload_to='paint/%Y/%m/%d')
price = models.CharField(max_length=50, blank=True, null=True)
status = models.CharField(choices=STATUS_PAINT, default=AVAILABLE, max_length=50)

class Meta:
verbose_name = "Picture"
verbose_name_plural = "Images"

def __unicode__(self):
return "{}".format(self.title)

Aucun commentaire:

Enregistrer un commentaire