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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:11:24+00:00 2026-06-01T04:11:24+00:00

Updated Problem solved, I have some design problem here. The directory looks like that:

  • 0

Updated Problem solved, I have some design problem here.

The directory looks like that:

/view
  |-__init__.py
  |-quiz.py
  |-test.py
  |-user.py

And the problem is that in quiz.py, I import a class from test. and in test.py, I import a class from quiz .

Updated: I changed import but there is still a AttributeError

The code as following:

quiz.py

#ignore some imports here
import test
from user import User

class Quiz(Document):
    creator         =   ReferenceField(User, reverse_delete_rule=CASCADE)
    info            =   GenericEmbeddedDocumentField("QuizInfo")
    description     =   StringField(max_length=100)
    attachment      =   GenericEmbeddedDocumentField("QuizAttach")
    correctanswer   =   GenericEmbeddedDocumentField("QuizAnswer")
    wronganswer     =   GenericEmbeddedDocumentField("QuizAnswer")
    manualdifficulty=   FloatField(min_value=0, max_value=1)
    autodifficulty  =   FloatField(min_value=0, max_value=1)
    checkout        =   GenericEmbeddedDocumentField("QuizCheckcout")
    tag             =   ListField(StringField(max_length=20))

#ignore some codes here

class QuizCheckout(EmbeddedDocument):
    time            =   DateTimeField()
    type            =   IntField()
    description     =   StringField()
    test            =   ReferenceField(test.Test, reverse_delete_rule=CASCADE)

test.py

import quiz


class Test(Document):
    createdate      =   DateTimeField()             #Create datetime
    description     =   StringField()               #decription of this test
    takennumber     =   IntField()                  #the number of students who may take this test
    quiz            =   GenericEmbeddedDocumentField('TestQuiz')

class TestQuiz(EmbeddedDocument):
    quiz            =   ListField(ReferenceField(quiz.Quiz, reverse_delete_rule=CASCADE))
                        #Reference to Quiz, if Quiz is deleted, this reference will be deleted too.
    correct         =   IntField()
                        #how many students got this right

and the error is

Exception Type: AttributeError Exception
Value: 'module' object has no attribute 'Quiz'

At first I thought that maybe a recursive problem, but I only find that I could move import into functions to avoid recursive import, but there is no functions here, and I try to move import into class, it don’t work.

Is there any way to keep these definition in separate file?

  • 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-06-01T04:11:26+00:00Added an answer on June 1, 2026 at 4:11 am

    Move QuizCheckout to a separate module. (QuizCheckout references Test at the class definition level, and Test references Quiz, that is the root of the problem)

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

Sidebar

Related Questions

(Problem solved, please see the updates) I have some files that have incorrect filenames
I have a website that is updated regularly and I am having a problem
I have a big big problem. Yesterday I updated the Android SDK and, since
I have a problem. When I updated Android SDK tool to version 17 and
Recently I updated my computer to Ubuntu 11.10 64-bits. I have a problem when
Based on some standard web searching, I have narrowed down my problem to this:
Is there a way of finding all the rows that have been updated by
update SOLVED - the problem is not with my code. there is a design
I finally solved one problem but now i have another. I found out how
UPDATE: First problem solved, second one described at the bottom of this post. UPDATE2:

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.