Rammanoj
Are you using token-based authentication ??
If so try django-rest-knox (as rest framework doesn't support multiple system token based auth)
Deleted Account
i am sorry. this is my first time use django. so that in my case, 'rest_framework.authtoken' is not suitable for me?
Rammanoj
i am sorry. this is my first time use django. so that in my case, 'rest_framework.authtoken' is not suitable for me?
I mean rest framework generates a single token for each user. So, if you login in two different systems, the same token will be returned both the times. It's okay in case of login. But in case of logout, if you logout in a specific device, then the token corresponding to the user gets deleted. This automatically logs user out from all the devices he is logged in.
Sanjay Krishnan
A doubt..which is more efficient..? Passing context variable or writing template tag for it?
Mirco
I think is more about reuse Writing a template tag is more convenient if u need that thing more and more
gamer_boy
i want to create multochoice question answer game in the website, what should i do
gamer_boy
i saw some projects on github...but they are very difficult to understand
Mirco
There are lots of questions/answers project example to give you an idea
gamer_boy
can you suggest me easiest one
Mirco
On official docs you can find polls app tutorial
R
There’s also this one: https://github.com/tomwalker/django_quiz it does not seem updated for newer django versions, although there’s some PR which should fix it and you could use, but if you new to django probably better to follow official docs polls app tutorial as Mirco suggests
Prinart
Please group members I need help seriously. Kindly help me out in my end of semester project. We have been given a project like school management system. You have a Student model which student will apply. In their application form they will select Their programme (e.g. B.A. Arts), Major (e.g. English) and Minor (e.g. French). After that you will have to get a Model that will assign courses to students base on the course combination (e.g. Someone offering Arts with English and French will offer English, French, Shakespeare etc) And the last model is able to score them. (Like quiz 1, quiz 2 and exams) Please kindly help me out. You people are my only hope. I have search online am not getting any help. Thanks for your help
Mirco
What kind of help ? You have all specs, try to put the basics by yourself otherwise you will never learn When you will have some Django specific errors, ask here again 😀 But if you don't try, you don't learn
Prinart
I have done the Student Model but how to link the to assign the courses base on their combination is my worry. Thanks
Mirco
Mmm explain better your goal
Prinart
Prinart: class Student(models.Model): PROGRAMME_CHOICES = ( ("B. A. Arts", "B. A. Arts"), ("B.sc. Mathematics", "B.sc. Mathematics")) MAJOR_CHOICES = ( ("English", "English"), ("French", "French"), ("Mathematics", " Mathematics")) MINOR_CHOICES = ( ("English", "English"), ("French", "French"), ("Economics", " Economics")) first_name = models.CharField(max_length=128) last_name = models.CharField(max_length=128) programme = models.CharField(max_length=128, choices=PROGRAMME_CHOICES) major = models.CharField(max_length=128, choices=MAJOR_CHOICES) minor = models.CharField(max_length=128, choices=MINOR_CHOICES)
Prinart
Now how to select all students with particular combinations and assign courses to them
Mirco
To assign courses to them, it's better to have Course model and link it to Student with fk
Mi
Hey, guys
Mi
What would you use to generate a PDF or a DOCX in a DRF backend and then download it from a vue frontend, for example?
Mi
I'm looking for the best way to do it all
Mi
I've though of using xhtml2pdf in the backend to generate the document and then sending it in a http response to the frontend
R
I've though of using xhtml2pdf in the backend to generate the document and then sending it in a http response to the frontend
Not used xhtml2pdf so can’t say nothing about it but I have used weasyprint for converting html to pdf and is nice and really easy to use, but has some limitations and reportlab which is really nice as you generate native pdf but not as easy (note that I think django docs recommends using reportlab and there is some kind if tutorial), if you want to generate .docx files, there’s python-docx which mainly fills a word template merge fields, also really easy to use
R
Regarding download, it really depends on your needs, I mean if generated doc needs to be stored afterwards, if it can be public, etc
Mi
Mmm those advices are very useful to me, thanks a lot
Mi
It doesn't need to be stored
R
You can probably generate the files in memory then
Sanjay Krishnan
<a href="path of file" download></a>
Mi
I mean, the user may have to download it and then save it to disk or whatever
R
I did it some time ago with python-docx, but don’t have access to that source anymore
Mi
Yes, I don't think storing in a database is needed
Mi
I read somewhere that there are two ways to send the document via django rest
Mi
Via base64 encoding, which I think is horrible
Mi
And via http response
Mi
I still need to see how to handle this in the frontend
R
https://docs.djangoproject.com/en/2.1/howto/outputting-pdf/ here’s the docs I was saying
R
I still need to see how to handle this in the frontend
Guess if you working with Vue, you use Axios, so this should be useful https://gist.github.com/javilobo8/097c30a233786be52070986d8cdb1743
Mi
Thanks a lot for your help and all these resources! 😁
R
Although this assumes you stored the file in media or smth like that
Mi
Yeah, maybe I can store it temporary and then delete it when downloaded
R
If generating files from memory, it might be different
Anonymous
How to send a verification mail to the user on email change ?? in rest framework
Anonymous
This ia a liink to my current code https://dpaste.de/unsz
Anonymous
It is working fine but I want to add email verification(to the new email) when the user updates his email, how to perform that?
Anonymous
Can you provide some example or documentation regarding to it, thanks
R
Quite easy to find... https://docs.djangoproject.com/en/2.1/topics/signals/
R
Simpleisbetterthancomplex also has some useful tutorial with examples
Anonymous
Thanks will look to that
Mirco
Thanks
Yw 😀
George
What would you use to generate a PDF or a DOCX in a DRF backend and then download it from a vue frontend, for example?
I use weasyprint, there is a table in which projects are compared. Mind that you should choose one compatible with django version u use and python3
Mi
Thanks, @trenixjetix that's one of my candidates indeed
George
I decided between two or three
George
Including reportlab
George
Simpleisbetterthancomplex also has some useful tutorial with examples
That tutorial is not that good. I dont see the need in storing in the filesystem. I saw better tutorials involving temporary files or even you dont have to store it in fs
George
And that is really important because you have to generate a pdf with a name, that if you got multiple users it may get overwrited
Mi
I think that reference was for another question
George
I know
Amd64
Heey everyone, assist me debug the error above
Sergei
Heey everyone, assist me debug the error above
Check the spelling of Class in views
George
Heey everyone, assist me debug the error above
dont send pictures of your screen
George
also, post your views in pastebin
Anders (izzno / gooood) 🇳🇴
Is there a way to add the "add" button when using "filter_horizontal" in admin ?
Mirco
I think there's always a way when u code 😂 Anyway you can always overwrite templates, styles about admin
Shubham
Anyone can help me in dialogflow??
Anders (izzno / gooood) 🇳🇴
Anonymous
hey there
Anonymous
i am thinking to add emotion detection to my django made website
Anonymous
can anybody help me like how i go with it
Anonymous
i googled and found I need to make an api and json gonna help
Mirco
Use Django Rest Framework
ibrahim süren
Guys what u use for json web tokens in rest api?