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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:25:41+00:00 2026-06-07T01:25:41+00:00

I have followed the tutorial (parts 1 and 2) on the Django site (https://docs.djangoproject.com/en/1.4/intro/tutorial01/)

  • 0

I have followed the tutorial (parts 1 and 2) on the Django site (https://docs.djangoproject.com/en/1.4/intro/tutorial01/) and have managed to create a couple folders and to connect to my website. My app is called ‘app’, so my folder structure looks a bit like:

  • mainFolder
  • —__init__.py
  • —test.py
  • —djangoSite (created by Django)
  • —— manage.py
  • —— djangosite
  • ——— other .py files
  • —— app
  • ———-__init__.py
  • ——— models.py
  • ——— other .py files

I changed the models.py file to be something like:

class Result(models.Model):
    options = models.CharField(max_length = 1000, unique = False)
    reverse = models.DecimalField(decimal_places = 6, max_digits = 12)

test.py currently runs a couple tests on some other classes. What I want is for my test.py class to run these tests and save the results in a database (in columns
and reverse). I was hoping to do something like this in my test.py class:

import models.py
if __name__ == "__main__":
    optionResult = someTestsThatRuns
    reverseResult = someOtherTestThatRuns
    models.Result c;
    c.options = optionResult 
    c.reverse = reverseResult 

I’d like for the last two lines to save the result in the database.
Is this possible? How would I import the models.py from the app folder?

Thank you

EDIT:
When I say someTestsThatRuns, these aren’t unit tests. They are practically a function that returns a list and some strings with either ‘PASS’ or ‘FAIL’. Sorry for the confusion

  • 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-07T01:25:43+00:00Added an answer on June 7, 2026 at 1:25 am

    Create an empty __init__.py file in the app folder so Python treats the directory as a package. Then do:

    from app.models import Result
    
    optionResult = someTestsThatRuns
    reverseResult = someOtherTestThatRuns
    c = Result()
    c.options = optionResult 
    c.reverse = reverseResult
    c.save()
    

    That will save ‘c’ to the database.

    Note that Django’s test suite can create its own test database, which runs tests on a separate database. You can read more about Django testing here.
    https://docs.djangoproject.com/en/dev/topics/testing/?from=olddocs

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

Sidebar

Related Questions

I have followed the instructions at http://www.javacodegeeks.com/2011/01/advanced-smartgwt-tutorial-part-1.html and tried to create a simple screen
I've followed this tutorial: https://developers.facebook.com/docs/opengraph/tutorial/ multiple times and always get the same result. I
Hi have followed this tutorial using Core plot framework http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application My project compiles, but
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
I have followed his popular tutorial to connect Android to MySQL: http://www.helloandroid.com/tutorials/connecting-mysql-database It is
I have followed this tutorial to get my ListView populating data -- http://android.amberfog.com/?p=296 .
I have followed this tutorial http://netbeans.org/kb/docs/websvc/gs-axis.html and successfully created the web service. When i
I have followed this tutorial: http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 fully, and after seing that I had issues
I have followed a tutorial on http://www.codeproject.com/KB/IP/beginningtcp_cpp.aspxt which teaches how to use winsockets with
http://www.devx.com/wireless/Article/39101/0/page/2 I have followed this tutorial and got it to work and everything. now

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.