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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:04:33+00:00 2026-06-02T01:04:33+00:00

To help myself learn Python, I’m writing a simple issue tracker using Django. I

  • 0

To help myself learn Python, I’m writing a simple issue tracker using Django.

I have two simple classes (left some code out for brevity), Issue and Version

There is an ISSUE_STATE tuple that is used to maintain an Issue‘s state:

ISSUE_STATE = (
    ('p', 'In Progress'),
    ('o', 'Open'),
    ('r', 'Resolved'),
    ('c', 'Closed'),
)

It’s maintained in the Issue like so:

class Issue(models.Model):
    state = models.CharField(max_length=1, choices=ISSUE_STATE)
    fix_version = models.ForeignKey(Version, related_name='issuesAsFix', null=True, blank=True, default=None)

(As you can also see, a Version maintains a list of Issue objects.)

The problem:

When I access the state of an individual Issue instance, it’s returned as a tuple. When I access the state of an Issue as provided by a Version object, it’s returned as a Unicode string:

>>> v = Version()
>>> v.save()

>>> i = Issue()
>>> i.fix_version = v
>>> i.state = ISSUE_STATE[1]
>>> i.save()

>>> i.state
('o', 'Open')
>>> v.issuesAsFix.all()[0].state
u"('o', 'Open')"

>>> i == v.issuesAsFix.all()[0]
True
>>> i is v.issuesAsFix.all()[0]
False

Why is the state variable of the Issue a string when accessed as a child property of the Version?

Thanks in advance!

  • 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-02T01:04:34+00:00Added an answer on June 2, 2026 at 1:04 am
    >>> i.state = ISSUE_STATE[1]
    

    This line is incorrect. It should be:

    >>> i.state = ISSUE_STATE[1][0]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently found myself becoming more negative about EF and cannot help wondering
I'm becoming acquainted with python and am creating problems in order to help myself
I'm super new to programming and I've been using appengine to help me learn
I'm trying to build a Chinese flashcards program in Java to help myself learn
I am creating a number guessing game to help myself learn how to use
I have come up with a small project to help me learn Java EE,
my question is maybe a dumb one, but i cant help myself - i
I've found myself in a situation, that makes me ask for help. I've got
I'm learning Java and find myself sending methods around while asking for help but
Help! I'm using the ASP.Net Login control on a Login page, but the Login

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.