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

  • Home
  • SEARCH
  • 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 140425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:36:45+00:00 2026-05-11T07:36:45+00:00

I need to be able to create a quiz type application with 20 some

  • 0

I need to be able to create a quiz type application with 20 some odd multiple choice questions.

I have 3 models: Quizzes, Questions, and Answers.

I want in the admin interface to create a quiz, and inline the quiz and answer elements.

The goal is to click ‘Add Quiz’, and be transferred to a page with 20 question fields, with 4 answer fields per each in place.

Here’s what I have currently:

class Quiz(models.Model):     label = models.CharField(blank=true, max_length=50)  class Question(models.Model):     label = models.CharField(blank=true, max_length=50)     quiz = models.ForeignKey(Quiz)  class Answer(models.Model):     label = models.CharField(blank=true, max_length=50)     question = models.ForeignKey(Question)  class QuestionInline(admin.TabularInline):     model = Question     extra = 20  class QuestionAdmin(admin.ModelAdmin):     inlines = [QuestionInline]  class AnswerInline(admin.TabularInline):     model = Answer     extra = 4  class AnswerAdmin(admin.ModelAdmin):     inlines = [AnswerInline]  class QuizAdmin(admin.ModelAdmin):     inlines = [QuestionInline, AnswerInline]  admin.site.register(Question, QuestionAdmin) admin.site.register(Answer, AnswerAdmin) admin.site.register(Quiz, QuizAdmin) 

I get the following error when I try to add a quiz:

class 'quizzer.quiz.models.Answer'> has no ForeignKey to <class 'quizzer.quiz.models.Quiz'> 

Is this doable, or am I trying to pull too much out of the Django Admin app?

  • 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-11T07:36:45+00:00Added an answer on May 11, 2026 at 7:36 am

    You can’t do ‘nested’ inlines in the Django admin (i.e. you can’t have a Quiz with inline Questions, with each inline Question having inline Answers). So you’ll need to lower your sights to just having inline Questions (then if you navigate to view a single Question, it could have inline Answers).

    So your models are fine, but your admin code should look like this:

    class QuestionInline(admin.TabularInline):     model = Question     extra = 20  class AnswerInline(admin.TabularInline):     model = Answer     extra = 4  class QuestionAdmin(admin.ModelAdmin):     inlines = [AnswerInline]  class AnswerAdmin(admin.ModelAdmin):     pass  class QuizAdmin(admin.ModelAdmin):     inlines = [QuestionInline] 

    It doesn’t make sense for AnswerAdmin to have an AnswerInline, or QuestionAdmin to have a QuestionInline (unless these were models with a self-referential foreign key). And QuizAdmin can’t have an AnswerInline, because Answer has no foreign key to Quiz.

    If Django did support nested inlines, the logical syntax would be for QuestionInline to accept an ‘inlines’ attribute, which you’d set to [AnswerInline]. But it doesn’t.

    Also note that ‘extra = 20’ means you’ll have 20 blank Question forms at the bottom of every Quiz, every time you load it up (even if it already has 20 actual Questions). Maybe that’s what you want – makes for a long page, but makes it easy to add lots of questions at once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 70k
  • Answers 70k
  • 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 See what EXPLAIN EXTENDED says. If it says DEPENDENT SUBQUERY… May 11, 2026 at 1:05 pm
  • added an answer A few I can think of are namespace pollution and… May 11, 2026 at 1:05 pm
  • added an answer That is the buffer for output, but a file upload… May 11, 2026 at 1:05 pm

Related Questions

I need to be able to create basic MS Project items (tasks, projects, resources,
In order to create the proper queries I need to be able to run
I need to be able to get at the full URL of the page
I need to be able to get a list of the groups a user
I need to be able to merge two (very simple) JavaScript objects at runtime.
I'm trying to create a dynamic popup window that is able to be re-sized.
I need to create a MarkupExtension for my WPF application that will need to
I need to create a request for a web page delivered to our web
I need to create a wizard for a Flash 9/ActionScript 3.0 application. The wizard

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.