5

मैं व्यवस्थापक/यूआरएल पर अपलोड विधि के साथ समस्या यह है:का प्रयास किया गया पहुँच/

अपनी सेटिंग्स में:

# Absolute filesystem path to the directory that will hold user-uploaded files. 
# Example: "/var/www/example.com/media/" 
MEDIA_ROOT = os.path.join(PROJECT_PATH, "media") 

# URL that handles the media served from MEDIA_ROOT. Make sure to use a 
# trailing slash. 
# Examples: "http://example.com/media/", "http://media.example.com/" 
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: "/var/www/example.com/static/" 
STATIC_ROOT = '' 

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

# Additional locations of static files 
STATICFILES_DIRS = (
    os.path.join(PROJECT_PATH, "static"), 
) 

# 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', 
) 

और मेरे LMS पर/models.py

MEDIA_TYPES = (
    ('Videos', 'Videos'), 
    ('Photos', 'Photos'), 
    ('PDF', 'PDF'), 
) 


class LessonFile(models.Model): 
    """ 
    The files for every lessons 
    """ 
    lesson = models.ForeignKey(Lesson) 
    documents = models.FileField(upload_to='/media/uploads/lms/lessons/') 
    title = models.CharField(max_length=255) 
    media_type = models.CharField(max_length=255, choices=MEDIA_TYPES) 

    def __unicode__(self): 
     return self.lesson 
पर मेरे व्यवस्थापक/

, जब मैं (अपलोड विधि द्वारा) एक दस्तावेज़ को बचाने की कोशिश:

'/ मीडिया/अपलोड/LMS/सबक/xxxx को

का प्रयास किया गया पहुँच। पीडीएफ 'मना कर दिया।

उत्तर

0

upload_to तर्क में अग्रणी स्लैश हटाने के बाद का प्रयास करें।

class LessonFile(models.Model): 
    ... 
    documents = models.FileField(upload_to='uploads/lms/lessons/') 
    ... 

अद्यतन: अपलोड_to तर्क में अतिरिक्त media निर्देशिका हटा दी गई।

+0

और यह दस्तावेज़ को PROJECT_PATH/मीडिया/मीडिया/अपलोड/एलएमएस/सबक/(डुप्लीकेट 'मीडिया' पर ध्यान दें) –

+0

सही, इसे अपडेट किया जाएगा। –

संबंधित मुद्दे