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 7186727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:41:40+00:00 2026-05-28T18:41:40+00:00

I am designing a quiz engine by using django. In the models.py, I have

  • 0

I am designing a quiz engine by using django.
In the models.py, I have such classes:

class Quiz (models.Model):
    quiz_id = models.AutoField (primary_key=True)
    problem_desc = models.TextField (blank=True)
    problem_has_resource = models.BoolField ()
    problem_is_choice = models.BooleanField ()
    def __unicode__ (self):
        return self.quiz_id

class Choice (models.Model):
    choice_id = models.AutoField (primary_key=True)
    quiz_id = models.ForeignKey (Quiz);
    choice_desc = models.CharField (max_length = 500)
    is_answer = models.BooleanField ()

class Answer (models.Model):
    quiz_id = models.ForeignKey (Quiz)
    input_answer = models.FloatField ()

class Quiz_Resource (models.Model):
    quiz_id = models.ForeignKey (Quiz)
    title = form.CharField (max_length = 50)
    file = forms.FileField ()
    def __unicode__ (self):
        return self.file.name

A quiz may need to be inputted an “Answer” or chosen a choice. A quiz may have many choices. A quiz may have some extra resource. I want the boolfield to control the admin page style, set formal info. How can I achieve it?

Bow, thanks!

enter code here

  • 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. Editorial Team
    Editorial Team
    2026-05-28T18:41:41+00:00Added an answer on May 28, 2026 at 6:41 pm

    First of all, you have to relate your quiz model to your Choice, Answer and Quiz_Ressource models.

    class Quiz (models.Model):
        name = models.TextField(max_length=50)
        problem_desc = models.TextField (blank=True)
        problem_has_resource = models.BoolField ()
        problem_is_choice = models.BooleanField ()
    
        choices=models.ManyToManyField(Choice)
        answers=models.ManyToManyField(Answer)
        ressources=models.ManyToManyField(Quiz_Ressource)
    

    That way you tell Django that your Quiz model references to multiple models of the type Choice, Answer and Quiz_Ressource. You can search for the concept of ManyToMany in relational databases if this is unclear.

    After you have rewritten your model like that, there will be fields for adding and selecting choices, anwers and ressources on the admin pages.

    To continue along with django use the documentation as provided here: https://docs.djangoproject.com/en/1.3/topics/db/models/#many-to-many-relationships

    Your needs for custom admin templates is a different story. You can do that with something like this in your apps admin.py:

    from django.contrib import admin
    from django.contrib.admin.sites import AdminSite
    from yourapp.models import Quiz
    
    class QuizAdminSite(AdminSite):
    
        def admin_quiz(request):
            #here goes your custom admin view code, where you can do
            #if has_ressource: return render_to_response('admin/quiz/has_ressource.html')
            #elif is_choice: return render_to_response('admin/quiz/is_choice.html')
            #and so on, you have to work out yourself how this has to look exactly
            return HttpResponse('your custom admin view')
    
        def get_urls(self):
        from django.conf.urls.defaults import *
        urls = super(ItemAdmin, self).get_urls()
        my_urls = patterns('',
            url(
                r'update_feeds',
                self.admin_site.admin_view(self.admin_quiz),
                name='admin_quiz',
            ),
        )
        return my_urls + urls    
    
    
    class QuizAdmin(QuizAdminSite):
        model=Quiz
    
    admin.site.register(Quiz,QuizAdmin)
    

    I don’t know exactly what you want to do with your custom admin view, so i skipped that part. But that should be the path to follow.

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

Sidebar

Related Questions

When designing LINQ classes using the LINQ to SQL designer I've sometimes needed to
When designing both the domain-model and class-diagrams I am having some trouble understanding what
When designing an rdlc report using the VS 2010 report designer, report items such
In designing my app, I have organized my UI with backbone.js, with each model
Designing code to handle transfers of objects called contractBundles. Have this in the models.py
Designing a new system from scratch. I'll be using the STL to store lists
When designing user table what would be the must have fields from the security/user
When designing a collection class, is there any reason not to implement locking privately
I'm in an intro level programming class and I have to make a grade
While designing applications it is a very good practice to have all the business

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.