Skip to main content
 首页 » 编程设计

python之在 OSQA (django python) 上添加问题时,它的正文是空的

2024年11月01日29kerrycode

我目前正在研究 OSQA,当我尝试从另一个问答网站导入一些问题和答案时,我遇到了很多麻烦。

发布前搜索,我在 meta.osqa 上找到了这个关于导入数据的链接,以及一些典型的错误,但它不再有效。 http://meta.osqa.net/questions/4080/how-can-i-import-data-from-another-question-and-answer-script

另一方面,我的代码是:

from django.core.management.base import NoArgsCommand 
 
from forum.models import * 
from forum.actions import * 
class Command(NoArgsCommand): 
    def handle_noargs(self, **options): 
        #retrieve the "asker" from the database 
        # "15" for Alumno Paco 
        user = User.objects.get(id=15) 
        #prepare question data 
        qdata = dict( 
           title = "Como funciona el TabViewController", 
           text = "No entiendo como funciona el TabViewController, alguna ayuda?", 
           tags = "iOS iPhone Xcode", 
        ) 
        #save the question, everything will be handled internally, 
        #like creating the tags if they don't exist, etc  
        AskAction(user=user).save(data=qdata) 

该命令在我的 OSQA 站点上正确创建了问题,除了问题的正文(文本)是空的。

奇怪的是,当手动添加问题时,直接从注册为用户的站点,它已成功创建。

阅读,我发现这是一个 Markdown 的问题,但我发现的解决方案不再适用,因为他们谈论编辑一个 mdx_urlizer.py 文件,它在当前版本的 OSQA 上不存在。

提前致谢!

奇可乐

请您参考如下方法:

markdown2.5 版本似乎有问题。

我通过安装markdown2.4版本解决了这个问题,即:

pip uninstall markdown 
pip install markdown==2.4