neutronX/django-markdownx

Ability to set a media path per MarkdownxField

ezarowny opened this issue · 0 comments

It would be helpful to be able to set the media path for any given MarkdownxField. Perhaps the default would be whatever is set for MARKDOWNX_MEDIA_PATH?

I'm thinking it would look something like FileField does today:

from django.db import models
from markdownx.models import MarkdownxField

class ModelClass(models.Model):
    markdownx_field = MarkdownxField(upload_to="some/path/")

or using a callable like

import uuid

from django.db import models
from markdownx.models import MarkdownxField

def _file_path_func(instance, filename):
    extension = filename.split(".")[-1]
    return "media/model-class-images/{}.{}".format(uuid.uuid4(), extension)

class ModelClass(models.Model):
    markdownx_field = MarkdownxField(upload_to=_file_path_func)