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

Related Questions

Alright I don't see why this isnt working. It seems pretty simple. Here is
Alright so I have been looking around (on SO and Google) to see if
Alright, so I'm new to Android programming, so far my experience has been quite
Alright. This may be difficult but I have been struggling for quite a bit
Alright, this problem seems to be way above my head! I have this code:
Alright so I just want to confirm something. I am creating a wrapper class
Alright it has come to this. I searched this website among many others and
Alright, so I know it is quite simple to print specific arguments of a
Alright, I'm at a loss here. I am trying to download a jar file
Alright so i need to open a .txt file that will be created in

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.