Django QR code tutorial | How to create QR codes in Django

  Рет қаралды 31,859

Pyplane

Pyplane

Күн бұрын

Пікірлер: 94
@Pyplane
@Pyplane 4 жыл бұрын
Hi again! Many of you asked me about the source code. It's available now at: github.com/hellopyplane/QR-codes-in-Django
@24webdevelopment
@24webdevelopment Жыл бұрын
404 . where is the sourcce code ?
@810Teams
@810Teams 4 жыл бұрын
6:20 For those who're having problems with the QR code's image size, replace line 17 with `canvas = Image.new('RGB', (qr_code_image.pixel_size, qr_code_image.pixel_size), 'white')` to make the image size automatically configured. Btw, nice video. This literally saved me quite time!
@Pyplane
@Pyplane 4 жыл бұрын
Thanks for the comment and for the remark on this! Cheers :)
@rubel1477
@rubel1477 3 жыл бұрын
Thanks
@wolfisraging
@wolfisraging 4 жыл бұрын
Excellent video buddy. Keep it up, KZbin seriously need good Django tutorials like this. Thanks.
@Pyplane
@Pyplane 4 жыл бұрын
Thank you Wolf!
@rlgraner
@rlgraner 4 жыл бұрын
Thanks for the video, it helped me a lot. For production, I had to set DEBUG to False, but when debugging is disabled, the image is not displayed. Any idea to solve it.
@Pyplane
@Pyplane 4 жыл бұрын
Hi Ricardo. You mean qr codes are not displayed or other images as well? I suggest to contact the hosting company customer service and ask for the proper media/static files for production
@rlgraner
@rlgraner 4 жыл бұрын
Hi@@Pyplane. Thank you very much for your quick response. All images, including the QR code, are not displayed. But that only happens when I change DEBUG to false. The problem also happens on the localhost.
@Pyplane
@Pyplane 4 жыл бұрын
@@rlgraner for local this is normal if you change debug to false, for going to production remember to fill out allowed hosts in the settings file and contact the hosting customer service to get the right configuration or try to find it online. good luck!
@hervebineli5327
@hervebineli5327 4 жыл бұрын
@@rlgraner Hi, try to use the package Whitenoise, it will save you from headaches whit serving Django static files in production.
@hervebineli5327
@hervebineli5327 4 жыл бұрын
Thank you very much for this video. Very clear and very well explaIned. Keep going on that way. I'm one of your followers.
@Pyplane
@Pyplane 4 жыл бұрын
Thank you very much !! :)
@franciscovinuesa7908
@franciscovinuesa7908 2 жыл бұрын
How many scans have these qrs ? could you cap those scans ? thank you
@sandeshbthapa2644
@sandeshbthapa2644 3 жыл бұрын
i was trying to make a form where you type name and it will be saved on out miodels and later we could see that but i dont know how to override the super save function we declared on our models
@Hamza-nu3xj
@Hamza-nu3xj 2 жыл бұрын
This is very good example but when we use many to many relationship in models the qrcode doesnt give the tag names properly
@JuanitoOrtega
@JuanitoOrtega 2 жыл бұрын
Thank you. Excuse me, how I can customize the image?.. For example: version, box_size, border?>>>
@Ghuhggyuugh8ijjjjhy4916
@Ghuhggyuugh8ijjjjhy4916 Жыл бұрын
thank you from Kazakhstan
@Hamza-nu3xj
@Hamza-nu3xj 2 жыл бұрын
How can we use this on many to many relationship?
@olaidealaka6802
@olaidealaka6802 3 жыл бұрын
Just what I was looking for. Thank you!
@Pyplane
@Pyplane 3 жыл бұрын
Thanks for watching!
@miles2590
@miles2590 4 жыл бұрын
Hi, do have a video on qrcode scanner using django? since qrcode is generated in djagno, I think, qrcode should be scan using djagno too. that would be great tutorial.
@Pyplane
@Pyplane 4 жыл бұрын
hi. in order to scan the qr code you need to have access to the camera. In django I don't it's possible. At least I don't know how to do it. It's quite easy if you are a mobile app developer using react native
@miles2590
@miles2590 4 жыл бұрын
@@Pyplane hi, thank you for the information.
@mehedihasannasim-
@mehedihasannasim- 2 жыл бұрын
you showed the name in qrcode, how can i show more than name from database in qrcode? its just show self.name
@oshershukrun4217
@oshershukrun4217 3 жыл бұрын
Hey dear, Lets say i want to do a reffer to profile1?id=3, profile2?id=5
@mustang174
@mustang174 Жыл бұрын
Excellente video. thanks a lot
@xBrenn4n
@xBrenn4n 4 жыл бұрын
Can i edit the qr code url later if i want to change where thw qr code redirects me?
@Pyplane
@Pyplane 4 жыл бұрын
Hi. The qr code will be updated everytime you save the object. So if you change i.e. website from pyplane.com to youtube.com - the qr code will change
@rahulmullick7316
@rahulmullick7316 4 жыл бұрын
awesome....! sir please build social-media websites....!
@Pyplane
@Pyplane 4 жыл бұрын
Thank you! :) I will make another social network project this time using django, drf and react js... coming soon :)
@rahulmullick7316
@rahulmullick7316 4 жыл бұрын
@@Pyplane pretty impressive...! i'm waiting for this...! thank you.....!
@oumaymasaddam5000
@oumaymasaddam5000 3 жыл бұрын
i have this error please help ! AttributeError: 'Settings' object has no attribute 'MEDIA_Root'
@gustinfauziah9231
@gustinfauziah9231 3 жыл бұрын
Hi. Thanks for the video. I keep getting an error "TemplateDoesNotExist at /home.html" Please help.
@mamangcikal1255
@mamangcikal1255 4 жыл бұрын
thank u so much bro, but can we do a scan then the scan adds the quantity of an item? thanks for supporting Django community
@Pyplane
@Pyplane 4 жыл бұрын
Hello Leric. I'm trying to understand what is the purpose of this solution. Besides you will be scaning the qr code with a smart phone, right? If you want to generate more than one QR code you can easily create a qr code generator. It can do a various things... i.e. generate QR codes which are the same (you choose the quantity) or for example you can create random qr codes based on random strings. Regards, Luke
@sakilanasrinsetu1057
@sakilanasrinsetu1057 4 жыл бұрын
This video is really awesome. But how to create qr code for multiple data?
@Pyplane
@Pyplane 4 жыл бұрын
Hi Sakila. I honestly haven't tried that so I can't answer your question
@JesusGil90
@JesusGil90 3 жыл бұрын
maybe like string "json" style
@mohamedfowzan8828
@mohamedfowzan8828 2 жыл бұрын
​@@JesusGil90 is there any reference to that? to generate qr code with json string in django?
@mohamedfowzan8828
@mohamedfowzan8828 2 жыл бұрын
@@Pyplane is there any reference to that? to generate qr code with json string in django?
@bryancirelly8116
@bryancirelly8116 4 жыл бұрын
Hello, excellent content, it was very useful for me to my final project. Now, how can i read a qr code with camera in django?
@Pyplane
@Pyplane 4 жыл бұрын
Hi Bryan. In django you just create qr codes which you can read by your phone. If you are using iphone you even don't have to install any app - just open up the camera and skan the code :)
@bryancirelly8116
@bryancirelly8116 4 жыл бұрын
@@Pyplane oh bro sorry for my bad explanation, i want to read each qr code inside application to get scanned user profile. How can i do it?
@Pyplane
@Pyplane 4 жыл бұрын
Bryan Cirelly still not sure I understand (sorry). The qr code should be based on the user profile? I created a qr code based on pyplane.com , in your case I would try to add a qr code to the profile model, so for each user you will have a value to put in the qr code. In example yoursite.com/profile1
@bryancirelly8116
@bryancirelly8116 4 жыл бұрын
@@Pyplane Sorry I'm bad at explaining, I'll try again being a little more specific. I have a patient profile that generates a qr code with their identification number, which would be printed (for when I attend a medical consultation). Within the application I need a scanner that reads the code and sends me directly to your profile. This to automate the search process within the app.
@Pyplane
@Pyplane 4 жыл бұрын
​@@bryancirelly8116 A patient comes, gives you his card where there is a qr code. You then decide to scan it with your phone? Unless you have a mobile app for this - I don't understand it. I would create a barcode generator and buy a scanner for $50, then I would place the barcodes on the patient card (instead of qrcode)...and you don't need your phone, everything can be taken care of from 1 app
@suleymanefecelik8750
@suleymanefecelik8750 4 жыл бұрын
Thank you so much, but images create twice. How can fix it? (qr-code-a.png and qr-code-a_St8BXhq.png)
@Pyplane
@Pyplane 4 жыл бұрын
Hi. Check your code to the one on source code available on github. The code presented there saves only one image. Good luck!
@suleymanefecelik8750
@suleymanefecelik8750 4 жыл бұрын
@@Pyplane I checked. def save(self, *args, **kwargs): qrcode_img = qrcode.make(f'192.168.1.50:8000/a/{self.business.pk}/{self.pk}') canvas = Image.new('RGB', (qrcode_img.pixel_size, qrcode_img.pixel_size), 'white') canvas.paste(qrcode_img) fname = f'qr-code-{self.name}.png' buffer = BytesIO() canvas.save(buffer, 'PNG') self.qr_code.save(fname, File(buffer), save=False) canvas.close() super().save(*args, **kwargs) I can't see any issiue
@suleymanefecelik8750
@suleymanefecelik8750 4 жыл бұрын
@@Pyplane Ooo I did. Ty :D
@JesusGil90
@JesusGil90 3 жыл бұрын
@@suleymanefecelik8750 how did you do it?
@JesusGil90
@JesusGil90 3 жыл бұрын
id None -.-
@Pyplane
@Pyplane 4 жыл бұрын
Hi Guys. Thanks for watching this video! If you're interested in Data Science, I have a FREE DS with Django course on my channel available under this Link: kzbin.info/www/bejne/mH3MlYpqnqesp9E
@nelsonkehinde4303
@nelsonkehinde4303 4 жыл бұрын
Hi. Thanks for the video. I keep getting an error - "qrcode has no attribute 'make'". Please help.
@nelsonkehinde4303
@nelsonkehinde4303 4 жыл бұрын
Hi. Please reply
@Pyplane
@Pyplane 4 жыл бұрын
Hi Nelson. Sorry for the late response. It's difficult for me to say anything without seeing your project code. If you follow the tutorial exactly step by step, such error should not take place. I use quite often qrcodes in the projects that I'm doing and never got such error. Sorry that I can't help on this. Regards, Luke
@nelsonkehinde4303
@nelsonkehinde4303 4 жыл бұрын
@@Pyplane okay. Thank you. Maybe I did something wrong. I have checked severally times till.... let me do it all over again one more time
@Pyplane
@Pyplane 4 жыл бұрын
@@nelsonkehinde4303 In case of problems you can write me an email info@pyplane.com
@nelsonkehinde4303
@nelsonkehinde4303 4 жыл бұрын
@@Pyplane Hi again, I created it all over again step by step and i got it this time. THank you very much. You're wonderful! Lol
@josephsierra1961
@josephsierra1961 4 жыл бұрын
Hi! This work perfect for string under 15 characters. When i want to convert an string ith 15+ characters it gives me like an off-screen qr that my cellphone cant read. Can u help me?
@josephsierra1961
@josephsierra1961 4 жыл бұрын
I think that was pretty logic haha Just adjust that 290,290 to bigger values. Thank you for your videos :D
@Pyplane
@Pyplane 4 жыл бұрын
Hi Joseph. Just tested scanning qr codes with 20 characters - works every time. Difficult for me to write anything more not knowing the details.
@josephsierra1961
@josephsierra1961 4 жыл бұрын
Ty very muchm Idk why that happened but I fixed it just changing the values to: Image.new('RGB',(360,360), 'white') when creating the canvas.
@Pyplane
@Pyplane 4 жыл бұрын
@@josephsierra1961 Awesome! Happy you figured it out :)
@alexis3170
@alexis3170 4 жыл бұрын
@@josephsierra1961 Thanks for this, spent hours looking online for answers to why my qrcode couldn't be scanned. Dynamically generating qrcodes in Django is a surprisingly obscure topic.
@vinsmokearifka
@vinsmokearifka 4 жыл бұрын
Life saver, thanks
@Pyplane
@Pyplane 4 жыл бұрын
Thanks for watching!
@forumkoding5921
@forumkoding5921 4 жыл бұрын
How to display the id instead of the item name? I have tried to replace the name with the id but the results are not displayed when the scan is done Thank you very much
@forumkoding5921
@forumkoding5921 4 жыл бұрын
because I need to be able to display the id when the scan is done
@november_pain
@november_pain 3 жыл бұрын
How to make it so photo will be deleted automatically after you delete it from db?
@JesusGil90
@JesusGil90 3 жыл бұрын
i think you should read about signals (pre_delete) and delete the file "manually"
@dibri
@dibri 4 жыл бұрын
i need help. doesnt work. cant save in the admin without providing a photo
@Pyplane
@Pyplane 4 жыл бұрын
Hi. If it doesn't work please check the source code and compare to yours. I'm dropping the link here: github.com/hellopyplane/QR-codes-in-Django
@Pyplane
@Pyplane 4 жыл бұрын
btw. if you named the qr_code field as photo make sure to set the imagefield as blank=True
@dibri
@dibri 4 жыл бұрын
Hey I already referred to your github but still nothing is there anyway to reach you personally? Maybe discord? Or email?
@MuhammadDavi
@MuhammadDavi 4 жыл бұрын
you declare draw variabel, but you don't use that....what for draw variable?
@Pyplane
@Pyplane 4 жыл бұрын
You're right. I was doing experiments with image new and image draw - both solution did work but accidently I added here image draw (although I wanted to present the other solution). You can ignore this line
@MuhammadDavi
@MuhammadDavi 4 жыл бұрын
@@Pyplane okey, thanks
@MuhammadDavi
@MuhammadDavi 4 жыл бұрын
@@Pyplane if i want add logo in my qr code, how i can read file image from static folder to my model?
@Pyplane
@Pyplane 4 жыл бұрын
@@MuhammadDavi it would be easier if you would put the logo and the image to a pdf. That's usually what I'm doing
@MuhammadDavi
@MuhammadDavi 4 жыл бұрын
@@Pyplane do you have blog or video that I made a reference? thanks
@foresttreehouse
@foresttreehouse 2 жыл бұрын
First of all, great video, it really helped me a lot. But after experimenting a little bit I think creating the canvas with Image and ImageDraw isn't actually necessary, it works just the same if you delete all code related to that and replace canvas.save(buffer, 'PNG') with qrcode_img.save(buffer, 'PNG'). Still, I like your approach to the problem so thumbs up!
@alvinng8338
@alvinng8338 3 жыл бұрын
Hi, sir, how if i want to have not just Name only from QR code, for example, I want to scan the QR code to retrieve the information of a profile like the username, address, email.... is it possible?
@Pyplane
@Pyplane 3 жыл бұрын
Hi Alvin. I’m doing the things you mentioned like this: I use the qrcode instead of pk in a mobile app. So once I scan the code a proper screen appears with all the details. We will create a similar app here on the channel in the near future. If you are looking for a different solution you’ll need to do the research on your own. Good luck!
@vuctuc737
@vuctuc737 4 жыл бұрын
Wow.
@rajshah7940
@rajshah7940 4 жыл бұрын
at least post github link
Django barcode generator | How to create barcodes in Django
15:42
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
Django To Do List App With User Registration & Login
2:12:03
Dennis Ivy
Рет қаралды 343 М.
Learn Django - Build an Asynchronous Chatroom with Django and Channels
1:31:27
Django signals for beginners | How to use signals in Django
54:32
Django and Stripe Payments Tutorial
1:10:27
Matt Freire
Рет қаралды 99 М.
Django + Chart.js // Learn to intergrate Chart.js with Django
26:45
CodingEntrepreneurs
Рет қаралды 232 М.
How to create a like button with counter in django
36:04
Pyplane
Рет қаралды 24 М.
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН