Skip to content

Ability to set a media path per MarkdownxField #264

@ezarowny

Description

@ezarowny

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions