+ 1

django question answer quiz

The question is here please help me. If you do not understand something, write it down https://stackoverflow.com/questions/65701628/combining-answer-and-question-fields-django

13th Jan 2021, 12:08 PM
kokito
8 Respostas
+ 2
I am not able to understand what you're not able to do. Can you please make clearer what the *exact* problem is? Anyways, I found 1 problem in your code. That is, in the definition of the `Answer` model (in models.py), the method name should be `__unicode__` (2 underscores before and after), but you have defined a method `_unicode__` (1 underscore before and 2 after). Also, the unicode() function was removed in Python 3. So I suggest you remove the __unicode__ method from your model and instead do def __str__(self): return self.answer Another suggestion: each question will have only 1 answer right? Then using one-to-one field instead of foreign-key is much better, because then you can directly get the answer to a question using `question.answer_question` and an answer's question using `answer.question` instead of `question.answer_question.all()[0]` https://docs.djangoproject.com/en/3.1/ref/models/fields/#django.db.models.OneToOneField https://docs.djangoproject.com/en/3.1/topics/db/examples/one_to_one/
13th Jan 2021, 12:31 PM
XXX
XXX - avatar
+ 1
kokito yes I understood what you want to do, but I am not able to understand the exact problem you're facing while doung that. I already pointed out 1 problem in your code. Try fixing that also.
13th Jan 2021, 1:06 PM
XXX
XXX - avatar
+ 1
Did the problem fix I pointed out make any difference? Can you copy-past the html file into a code and attach it here (or in your question), because how can I see the problem without seeing the file? Also, I haven't done Django in a long time now, so please bear if I sound a bit confused.
13th Jan 2021, 1:32 PM
XXX
XXX - avatar
+ 1
All right
13th Jan 2021, 1:37 PM
XXX
XXX - avatar
0
XXX To explain it to you more precisely. I want all the questions to be in the loop and appear on the second page. Below these questions I want to be the input that is responsible for the Answer model and when I enter something and click submit it is stored in the database. (In Answer model)
13th Jan 2021, 1:00 PM
kokito
0
XXX understand?
13th Jan 2021, 1:01 PM
kokito
0
XXX My problem is that I could not compile the html accordingly. That is, to display the form correctly
13th Jan 2021, 1:20 PM
kokito
0
Can I write to you in PM? XXX
13th Jan 2021, 1:35 PM
kokito