feat(annonces): spécifie le dossier upload de fichiers
Parent
bc7d57da94
révision
e2dffd82df
|
@ -2,7 +2,7 @@ import uuid
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from django.urls import reverse
|
||||
from django.utils import formats, timezone
|
||||
from django.utils import formats, timezone, text
|
||||
from django.template.loader import render_to_string
|
||||
from django.core import validators
|
||||
from django.conf import settings
|
||||
|
@ -1112,8 +1112,13 @@ class AnnonceIndex(mixins.UniqPage, mixins.SiteCommonIndex, SitePage):
|
|||
|
||||
|
||||
class Image(ClusterableModel):
|
||||
def get_image_path(image, filename):
|
||||
return "annonces/{}/{}".format(
|
||||
image.annonce.id,
|
||||
text.get_valid_filename(filename),
|
||||
)
|
||||
annonce = ParentalKey('Annonce', related_name='images')
|
||||
image = models.ImageField("Image")
|
||||
image = models.ImageField("Image", upload_to=get_image_path)
|
||||
|
||||
|
||||
class Annonce(SitePage, mixins.GeoLocated):
|
||||
|
|
Chargement…
Référencer dans un nouveau ticket