Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to set a media path per MarkdownxField #264

Open
ezarowny opened this issue Feb 6, 2024 · 0 comments
Open

Ability to set a media path per MarkdownxField #264

ezarowny opened this issue Feb 6, 2024 · 0 comments

Comments

@ezarowny
Copy link
Contributor

ezarowny commented Feb 6, 2024

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant