title: Django, Python, and Class Variables
body: <p>I'm simultaneously learning Python while picking up Django. I'm familiar with many other languages.</p>
  
  <p>In the following code snippet, <code>x</code> is a class variable of class <code>Foo</code>.</p>
  
  <pre><code>class Foo(object):
      x = 9000
  </code></pre>
  
  <p>Given the previous declaration, the following works fine.</p>
  
  <p><code>print Foo.x</code></p>
  
  <p>The Django framework lets you create your model by defining Python classes. It makes fields out of the different class variables in your Python classes.</p>
  
  <pre><code>class Question(models.Model):
      question_text = models.CharField(max_length=200)
  </code></pre>
  
  <p>Why does the following code snippet:</p>
  
  <pre><code>#!/usr/bin/env
  import os, django
  os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
  django.setup()
  from polls.models import Question, Choice
  print Question.question_text
  </code></pre>
  
  <p>throw the following error:</p>
  
  <pre><code>AttributeError: type object 'Question' has no attribute 'question_text'
  </code></pre>
  
  <p>As far as I'm understanding everything my <code>Question</code> class has a single static member defined: <code>Question.question_text</code>.</p>