title: Django - Foreign Key not working
body: <p>I'm trying to display some data on a webpage using a foreach loop and django.
  I do not seem to understand how to use a lookup table that I have created in my Database.</p>
  
  <p>These are the columns from the DB:</p>
  
  <pre><code>budget_audit_table:
  -BudgetID
  -BudgetTypeID &lt;- Foreign Key
  -ObjectAuditID
  -CustomerID
  -DateOfTransaction
  -BudgetObject
  -Amount
  
  budget_type:
  -BudgetTypeID
  -BudgetType
  </code></pre>
  
  <p>As you can probably assume in the model.py, the BudgetTypeID is a foreign key.
  In the budget_type table I currently have 2 rows:
  - Expense: ID 1
  - Income: ID 2</p>
  
  <p>Now the problem I'm having is I have searched for a few days now trying to understand Django's API more and I'm struggling to understand how do I for each row that is displayed from the budget_audit_table, how do I instead of displaying the BudgetTypeID (eg 1), it displays the BudgetType (eg Expense)?</p>
  
  <p>Here is my view &amp; template</p>
  
  <p>view.py</p>
  
  <pre><code>from django.contrib.auth.decorators import login_required
  from django.http import HttpResponse
  from django.template import RequestContext, loader
  from models import BudgetAuditTable
  from models import BudgetType
  
  @login_required
  def index(request):
      budgetauditlist = BudgetAuditTable.objects.order_by('-budgetid')
      template = loader.get_template('budget/budget.html')
      context = RequestContext(request, {
          'budgetauditlist': budgetauditlist,
      })
      return HttpResponse(template.render(context))
  </code></pre>
  
  <p>Template</p>
  
  <pre><code>{% for budgetauditobject in budgetauditlist %}
  &lt;tr&gt;
      &lt;td&gt;{{ budgetauditobject.budgetid }}&lt;/td&gt;
      &lt;td&gt;{{ budgetauditobject.budgettypeid }}&lt;/td&gt;
      &lt;td&gt;{{ budgetauditobject.objectauditid }}{{ budgetauditobject.customerid }}&lt;/td&gt;
      &lt;td&gt;{{ budgetauditobject.amount }}&lt;/td&gt;
  &lt;/tr&gt;
  {% endfor %}
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>class BudgetAuditTable(models.Model):
      budgetid = models.IntegerField(db_column='BudgetID', primary_key=True)
      budgettypeid = models.ForeignKey('BudgetType', db_column='BudgetTypeID', blank=True, null=True)
      objectauditid = models.IntegerField(db_column='ObjectAuditID', blank=True, null=True)
      customerid = models.IntegerField(db_column='CustomerID', blank=True, null=True)
      dateoftransaction = models.DateField(db_column='DateOfTransaction', blank=True, null=True)
      budgetobject = models.CharField(db_column='BudgetObject', max_length=255, blank=True)
      amount = models.DecimalField(db_column='Amount', max_digits=10, decimal_places=2, blank=True, null=True)
  
      class Meta:
          managed = False
          db_table = 'budget_audit_table'
  
  class BudgetType(models.Model):
      budgettypeid = models.IntegerField(db_column='BudgetTypeID', primary_key=True)
      budgettype = models.CharField(db_column='BudgetType', max_length=25, blank=True)
  
      class Meta:
          managed = False
          db_table = 'budget_type'
  </code></pre>