如何将函数从view.py传递到html

时间:2019-10-24 02:22:47

标签: python django

views.py

def detect_full_text(tweet):
if 'retweeted_status' in tweet.*_json*:
    analysis_tweet =  tweet._json['retweeted_status']['full_text']
else:
    analysis_tweet = tweet.full_text
return (analysis_tweet)

public_tweet.html

{%用于分析%%}

  <tr>  

    <td>  
      {{ detect_full_text(analyze) }}

    </td>
    <td>  
      {{ analyze.created_at }} 
    </td>
    <td>  
      {{ analyze.favorite_count }} 
    </td>
    <td>  
      {{ analyze.retweet_count }} 
    </td>


  </tr>

  {% endfor %}

我想从html页面中的view.py调用python函数

0 个答案:

没有答案