django question answer quiz | SoloLearn: Learn to code for FREE!

+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

1/13/2021 12:08:15 PM

kokito

8 Answers

New Answer

+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/

+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.

+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.

+1

All right

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)

0

XXX understand?

0

XXX My problem is that I could not compile the html accordingly. That is, to display the form correctly

0

Can I write to you in PM? XXX