Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 146619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:38:08+00:00 2026-05-11T08:38:08+00:00

Alright, I’m at a loss with the Django Forms, as the documentation just doesn’t

  • 0

Alright, I’m at a loss with the Django Forms, as the documentation just doesn’t seem to quite cover what I’m looking for. At least it seems to come to a screeching halt once you get past the most rudimentary of forms. I’m more than willing to take a link to good documentation, or a link to a good book that covers this topic, as an answer. Basically, this is how it breaks down, I have 3 models (quiz, questions, answers). I have 20 questions, with 4 potential answers (multi-choice), per quiz. The numbers can vary, but you get the point.

I need to create a form for these items, much like you’d expect in a multiple choice quiz. However, when I create the form by hand in the templates, rather than using django.forms, I get the following:

invalid literal for int() with base 10: ‘test’

So I’m trying to mess with the django.forms, but I guess I’m just not grasping the idea of how to build a proper form out of those. Any help would be greatly appreciated, thanks.

For what it’s worth here are the models:

class Quiz(models.Model):     label = models.CharField(blank=True, max_length=400)     slug = models.SlugField()      def __unicode__(self):         return self.label  class Question(models.Model):     label = models.CharField(blank=True, max_length=400)     quiz = models.ForeignKey(Quiz)      def __unicode__(self):         return self.label  class Answer(models.Model):     label = models.CharField(blank=True, max_length=400)     question = models.ForeignKey(Question)     correct = models.BooleanField()      def __unicode__(self):         return self.label 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:38:09+00:00Added an answer on May 11, 2026 at 8:38 am

    Yeah I have to agree the documentation and examples are really lacking here. The is no out of the box solution for the case you are describing because it goes three layers deep: quiz->question->answer.

    Django has model inline formsets which solve the problem for two layers deep. What you will need to do to generate the form you want is:

    1. Load up a quiz form (just a label text box from your model)
    2. Load a an question formset: QuestionFormSet(queryset=Question.objects.filter(quiz=quiz))
    3. For each question load up a answer formset in much the same way you load up the question formset
    4. Make sure you save everything in the right order: quiz->question->answer, since each lower level needs the foreign key of the item above it
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 72k
  • Answers 72k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I changed the containing form to just construct a new… May 11, 2026 at 1:30 pm
  • added an answer That form of character access is not part of the… May 11, 2026 at 1:30 pm
  • added an answer You can't declare an array using a variable so Byte… May 11, 2026 at 1:30 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.