当我需要从post.title文本创建二维编码时,我在管理面板中添加帖子
我尝试使用django-qr代码库和ContactDetail模型,但出现错误:**之后的类型对象参数必须是映射,而不是Post
views.py def索引(要求):
# Use a ContactDetail instance to encapsulate the detail of the contact.
posts = Post.objects.all()
contact_detail = ContactDetail(
first_name=Post.objects.get())
# Use a WifiConfig instance to encapsulate the configuration of the connexion.
# Build context for rendering QR codes.
context = dict(
posts=posts,
contact_detail=contact_detail,
)
# Render the index page.
return render(request, 'blog/post_list.html', context=context)
models.py
class Post(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
title = models.CharField(max_length=400)
html
{% qr_for_contact contact_detail=contact_detail size='S' %}