Comments (8)
Hi StudentDwid,
I was able to get it working by rendering the markdown in views.py then passing it to templates. I wanted to render the text in the object post.text then pass it to templates to render blog/post_list.html.This is how it looks:
views.py:
from markdownx.utils import markdownify
posts = Post.objects.filter(published_date__lte=timezone.now())
def post_list(request):
for post in posts:
post.text = markdownify(post.text)
return render(request, 'blog/post_list.html', {'posts': posts})
post_list.html:
<div class="post">
<h1>
<a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }}</a>
</h1>
<p>{{ post.text|safe }}</p>
</div>
from django-markdownx.
It`s work, Thank you 😄
from django-markdownx.
No problem, glad its working for you. 😃
from django-markdownx.
this doesn't work for me :(
from django-markdownx.
I have a paginator with this
class PostListView(ListView):
model = Post
paginate_by = 5
template_name = 'post_list.html'
queryset = Post.objects.filter(published_date__lte=timezone.now()).order_by('-published_date')
and I can't do markdownify(post.text)
from django-markdownx.
I got it!
class PostListView(ListView):
model = Post
paginate_by = 5
template_name = 'post_list.html'
change my query before returns
def get_queryset(self):
posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('-published_date')
for post in posts:
post.text = markdownify(post.text)
return posts
from django-markdownx.
Is there a solution for "unmarkdownify"?
I have an update_view and get the plain HTML text back on editing. It is not usable for other users
from django-markdownx.
sujan-sube this works for me - I'm new to markdownx as of 2 days ago. This example helped me get things working the way I like. May I suggest adding it to the docs? I think it deals with #74 too.
from django-markdownx.
Related Issues (20)
- Create a release for the package HOT 2
- ImportError: cannot import name 'url' from django.conf.urls HOT 3
- DOC bug in link GITHUB 404 HOT 1
- Django 4 and file upload produces error HOT 5
- Using absolute paths for images? HOT 3
- Found a possible security concern HOT 2
- No cookie with key "csrftoken". Wrong name?
- Can't type `[` or `]` using a french keyboard on Windows
- MARKDOWNX_EDITOR_RESIZABLE does not appear to work in v4
- Can't add multiline code block HOT 1
- Release for Django 4.0 HOT 2
- getCookie() bug? HOT 1
- Simple optimization inside views.py HOT 1
- AttributeError on markdownify HOT 1
- A recent Upload and markdownify path errors
- How to customize the textarea cols HOT 2
- Cross-Site Scripting (XSS) Vulnerability in Markdown Library HOT 1
- AttributeError when using pillow >=10.0
- Css for dark theme in admin page
- Contact email to report a vulnerability does not exists HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-markdownx.