Package: wagtail-qrcode
Wagtail QR codeThis package can be used to create a page in Wagtail CMS that has a corresponding QR Code.FeaturesThe generated QR Code is saved as an EPS document that can be printed. When scanned IT will link to the page via a redirect using the page IDYou can download the generated QR code and use it in printed advertising like posters, postcards, banners, beer mats and more.When saving a draft or publishing a page you can add a one-time email address to send the qr-code to as an attachment.InstallationTo add the package to your own Wagtail CMSInstall the package into your environment.pipinstallwagtail-qrcodeAdd the package to your site settings.INSTALLED_APPS=[# ..."wagtail_qrcode",# ...]Add this setting to your Wagtail settings.It is used to generate the base url for the QR codeWAGTAIL_QR_CODE_BASE_URL="your-site-url"You'll likely want to test the QRcode using another device. Your device will need to be able to resolve your testing domain and localhost probably won't work.Try using a service likengrokto set up a url to your localhost and use that domain name as in theWAGTAIL_QR_CODE_BASE_URLsetting.This is the command I use to start ngrok../ngrokhttp8000--scheme=httpUsing the QRCode page model mixinUse the model mixin in a new or an existing page model.# models.pyfromwagtail.admin.panelsimport(FieldPanel,MultiFieldPanel,ObjectList,TabbedInterface,)fromwagtail.modelsimportPagefromwagtail_qrcode.admin_formsimportQrCodeEmailFormfromwagtail_qrcode.modelsimportQRCodeMixinclassQRCodePage(QRCodeMixin,Page):qrcode_panels=QRCodeMixin.panels+[MultiFieldPanel([FieldPanel("email_address"),FieldPanel("email_subject"),FieldPanel("email_body"),],heading="Send QR code via email",)]edit_handler=TabbedInterface([ObjectList(Page.content_panels,heading="Content"),ObjectList(Page.promote_panels,heading="Promote"),ObjectList(Page.settings_panels,heading="Settings",classname="settings"),ObjectList(qrcode_panels,heading="QR Code",classname="qr-code"),])base_form_class=QrCodeEmailFormThis will add a new tab in the page editorQR Codewhere you can preview the generated QR code and access the downloadable print ready EPS file. (the file can also be found in the documents app)If you don't need to be able to send the qrcode via email your page model can be# models.pyfromwagtail.admin.panelsimport(FieldPanel,MultiFieldPanel,ObjectList,TabbedInterface,)fromwagtail.modelsimportPagefromwagtail_qrcode.modelsimportQRCodeMixinclassQRCodePage(QRCodeMixin,Page):qrcode_panels=QRCodeMixin.panelsedit_handler=TabbedInterface([ObjectList(Page.content_panels,heading="Content"),ObjectList(Page.promote_panels,heading="Promote"),ObjectList(Page.settings_panels,heading="Settings",classname="settings"),ObjectList(qrcode_panels,heading="QR Code",classname="qr-code"),])URLSInclude the wagtail-qrcode urls in your site urls beforewagtail_urls.The url provides the redirect endpoint when the qr-code is scanned and viewed in a browser.urlpatterns=[# ...path("qr-code/",include("wagtail_qrcode.urls")),# ...]or import the view and pass the view in the path functionfromwagtail_qrcode.viewsimportqr_code_page_viewurlpatterns=[# ...path("qr-code/",qr_code_page_view,name="qr-code-view"),# ...]ConfigurationSet the configuration (optional, these are the defaults)WAGTAIL_QR_CODE={"collection_name":"QR Codes","scale":3,"quiet_zone":6,"svg_has_xml_declaration":False,"svg_has_doc_type_declaration":False,}collection_name: is automatically created and used as the collection for all generated QR codesscale: the size of the dots in the QR codequiet_zone: the plain border around the QR codesvg_has_xml_declaration: does the QR code SVG have an XML declarationsvg_has_doc_type_declaration: does the QR code SVG have an HTML doc-typeContributingIf you would like to suggest an improvement to the packagecontributionsare welcomeIssuesIf you find an issue please considerraising and issue