【问题标题】:Facebook like button integrating in django templateFacebook like 按钮集成在 django 模板中
【发布时间】:2014-06-21 08:26:32
【问题描述】:

我正在尝试使用此代码在我的网页上添加点赞按钮

<iframe src="http://www.facebook.com/plugins/like.php?href={{request.build_absolute_uri}}&amp;layout=button_count&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100%; height:80px;" allowTransparency="true">
    </iframe>
<style>.fbook{position: absolute; font-color:#ddd; top:-1668px; font-size:10;}</style>
                </style>
<a href="http://www.druckerverwaltung.de‎" class="fbook">Immer neue Informationen...</a> 
<a href="http://www.videobeamer24.de" class="fbook">Eine neue Bestenliste im Netz</a> 
<a href="http://www.howtoaddlikebutton.com" class="fbook">click</a>
<style>.fbook-style_map:initreaction=10false_attempt10-border</style>
<style>closemap"init"if=fb_connect-start="25"check_bandwith</style>

但在第一行中,我希望在 django 模板中动态显示当前页面的 url,所以我使用了 {{request.build_absolute_uri}},但它不起作用,虽然没有错误,但它没有像按钮一样显示。

它是正确的模板标签还是我必须做其他事情?

【问题讨论】:

  • 你有要求安装中装吗?

标签: django facebook python-2.7 django-templates


【解决方案1】:

将此变量从视图传递到模板,

full_url = request.build_absolute_uri(None)

# pass full_url into the template context.

https://docs.djangoproject.com/en/1.6/ref/request-response/#django.http.HttpRequest.build_absolute_uri

【讨论】:

  • 我们可以不从视图渲染吗?我的意思是直接把这个request.build_absolute_uri标签放在django模板或类似的方法中。
猜你喜欢
  • 2012-09-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-23
  • 1970-01-01
  • 2013-01-14
  • 2012-05-17
相关资源
最近更新 更多