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

Django admin escapes sharable urls #139

Open
tartieret opened this issue Sep 2, 2021 · 0 comments
Open

Django admin escapes sharable urls #139

tartieret opened this issue Sep 2, 2021 · 0 comments
Labels

Comments

@tartieret
Copy link

Bug description

In the admin portal, django escape the sharable url for all blog posts, so the display looks like this:
image

Instead, this page should display a clickable html link for each blog post.

This issue is caused by using a readonly field in the PostAdmin class, without marking the html string as "safe".

return '<a href="{}">{}</a>'.format(obj.sharable_url, obj.sharable_url)

Step to reproduce

Create a new post through the admin portal, then visit the list of blog posts.

Additional context
Using django 3.1 but the problem exists with other versions of Django

Solution

The fix is easy, we just have to mark the html as safe to be displayed, using:

from django.utils.safestring import mark_safe

def show_secret_share_url(self, obj):
     return mark_safe( '<a href="{}">{}</a>'.format(obj.sharable_url, obj.sharable_url))

I am happy to submit a pull request to fix it, but is this project still maintained? it shows very little recent activity. More generally speaking, this package perfectly fits my need for a current project, so I am happy to spend some time on it if you are looking for maintainers.

@tartieret tartieret added the bug label Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant