stephanekirsch / e-colle

Application web de gestion de colles en CPGE basée sur Python3/Django
GNU Affero General Public License v3.0
10 stars 16 forks source link

Erreur 500 - Problème serveur lors de la tentative d'ajout de pdf à un programme de colle #59

Closed jowe19 closed 3 years ago

jowe19 commented 3 years ago

Bonsoir, Tout est dans le titre. Lorsque je tente d'ajouter un pdf à un programme de colle, j'ai un message Erreur 500. Voici le détail : Environment:

Request Method: POST
Request URL: https://ecolle.prepabarthou.fr/colleur/action/programme/12

Django Version: 3.1.1
Python Version: 3.7.3
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'accueil.apps.accueilConfig',
 'administrateur.apps.administrateurConfig',
 'eleve.apps.eleveConfig',
 'colleur.apps.colleurConfig',
 'secretariat.apps.secretariatConfig',
 'app_mobile.apps.appMobileConfig',
 'customfilter.apps.customfilterConfig',
 'ckeditor')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.7/dist-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/var/www/html/e-colle/colleur/views.py", line 249, in programme
    form.save()
  File "/usr/local/lib/python3.7/dist-packages/django/forms/models.py", line 460, in save
    self.instance.save()
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 754, in save
    force_update=force_update, update_fields=update_fields)
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 792, in save_base
    force_update, using, update_fields,
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 895, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 935, in _do_insert
    using=using, raw=raw,
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/query.py", line 1249, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/sql/compiler.py", line 1396, in execute_sql
    for sql, params in self.as_sql():
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/sql/compiler.py", line 1341, in as_sql
    for obj in self.query.objs
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/sql/compiler.py", line 1341, in <listcomp>
    for obj in self.query.objs
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/sql/compiler.py", line 1340, in <listcomp>
    [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/sql/compiler.py", line 1291, in pre_save_val
    return field.pre_save(obj, add=True)
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/fields/files.py", line 305, in pre_save
    file.save(file.name, file.file, save=False)
  File "/usr/local/lib/python3.7/dist-packages/django/db/models/fields/files.py", line 87, in save
    self.name = self.storage.save(name, content, max_length=self.field.max_length)
  File "/usr/local/lib/python3.7/dist-packages/django/core/files/storage.py", line 52, in save
    return self._save(name, content)
  File "/usr/local/lib/python3.7/dist-packages/django/core/files/storage.py", line 267, in _save
    fd = os.open(full_path, self.OS_OPEN_FLAGS, 0o666)

Exception Type: PermissionError at /colleur/action/programme/12
Exception Value: [Errno 13] Permission denied: '/var/www/html/e-colle/media/programme/progQydV1mRyUxibFte9hDEx.pdf'
stephanekirsch commented 3 years ago

Bonjour, C'est clairement un problème de droit sur le répertoire média. Il faut qu'Apache ( si c'est bien apache que tu utilises) ait les droits en écriture sur le répertoire média. Rien qu'un chown et/ou un chmod ne puisse résoudre. Le plus simple si ce n'est pas déjà fait est de créer un group 'web' par exemple, y ajouter l'utilisateur www-data ( Apache) et donner les droits en écriture au répertoire média à ce groupe.

jowe19 commented 3 years ago

C'est réglé, merci !

stephanekirsch commented 3 years ago

De rien!