基本上,我要做的是在文章中找到URL,例如,如果我发布以下内容:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
https://www.youtube.com/watch?v=example
它看起来是这样的: Lorem ipsum悲哀地坐在阿梅特的位子上,奉献给精英们,为他们提供临时的劳动和巨大的财富。你知道吗
你知道吗型号.py地址:
from django.db import models
class NewsFeed_Articles(models.Model):
title = models.CharField(max_length = 120)
post = models.TextField()
date = models.DateTimeField()
def __str__(self):
return self.title
你知道吗邮政.html地址:
{% extends "Feed/wrapper.html" %}
{% block content %}
<div class="card">
<h2 class="text-info">{{newsfeed_articles.title}}</h2>
<h6 class="text-info">{{newsfeed_articles.date|date:"d-m-Y в H:i:s"}}</h6>
<p>{{newsfeed_articles.post|safe|linebreaks}}<p>
<div class="fakeimg" style="height:200px;">Image</div>
</div>
{% endblock %}
使用以下代码将YouTube URL转换为YouTube嵌入:
下面是一个可以自己测试的工作示例:repl.it/@misir_ceferov/PythonYt2Embed
另外,您可以在这里测试正则表达式:regex101.com/r/97yhSH/1
更新
代码被简化了。你知道吗
相关问题 更多 >
编程相关推荐