Skip to content

QR Code Generator with Django

twitter logo github logo ・1 min read  

Hi devs! I'm wondering how you would generate your own QR code and add them over to your Django app? I've seen and tried different QR code generator but all of them only supports PDF, Images, Urls, and etc. I'm looking to generate a QR code of an object.

Not getting it? 🤔

It's like there's a QR code and then it returns to me an object like so:
{name: ' on', age: null, job: 'Developer'}

That way I can like open a dialog and just input the data to the input value or something.

By the way I'm using this on a React-Native app. 😁


twitter logo DISCUSS (4)
markdown guide

Well, as far as I can see this is a security risk no matter how you do it, unless you restrict the feature to dev environments.

If it's for dev only, then you should probably be fine using eval etc.

What I would do is use the python qrcode module, and pass it the object (in json format) as a string. On the other end, get that string output from the qr decoder and run json.load to get your object.


Is that so? Why is it a security risk?


It could potentially be used for arbitrary code execution.

I suppose if you very strictly check your JSON first you might be fine, so maybe I should revise "no matter how you do it" to "unless you're very careful."

Ahh. Gotcha. So I'll need to strictly check the JSON if I'm going to implement QR code with json.

Classic DEV Post from Jul 21 '19

What's hard about React Hooks for you?

React Hooks are amazing, but require a learning curve... What's it been like for you?

Ben Prax profile image
I'm an absolute noob who feeds his curiosity.
Sign up (for free) is where software developers stay in the loop and avoid career stagnation.