Commits

Anonymous committed 4e67180

accounts view working with django template, view

  • Participants
  • Parent commits 7a836a6

Comments (0)

Files changed (7)

 OWLSQL=../owlsql
 
 
-qdb.py: qdb.owl $(OWLSQL)/owl2django.xsl
+qfm/models.py: qdb.owl $(OWLSQL)/owl2django.xsl
 	$(XSLTPROC) --novalid -o $@ $(OWLSQL)/owl2django.xsl qdb.owl
 
 qdb.sql: qdb.owl $(OWLSQL)/owl2sql.xsl

File qdb.py

-from django.db import models
-
-class Account(models.Model):
-    id = models.AutoField(primary_key=True)
- 
-    name = models.CharField(maxlength=80, null=True)
-
-    def __str__(self):
-        return self.name
- 
-    parent = models.ForeignKey('self', null=True)
- 
-
-    class Admin:
-        pass
-
-
-class Job(models.Model):
-    id = models.AutoField(primary_key=True)
- 
-    name = models.CharField(maxlength=80, null=True)
-
-    def __str__(self):
-        return self.name
- 
-
-    class Admin:
-        pass
-
-
-class Transaction(models.Model):
-    id = models.AutoField(primary_key=True)
- 
-    acct = models.ForeignKey(Account, null=True)
- 
-    date = models.DateField()
- 
-    payee = models.CharField(maxlength=80, null=True)
- 
-    num = models.CharField(maxlength=80, null=True)
- 
-    ty = models.CharField(maxlength=80, null=True)
- 
-    memo = models.CharField(maxlength=80, null=True)
- 
-
-    class Admin:
-        pass
-
-
-class Split(models.Model):
-    id = models.AutoField(primary_key=True)
- 
-    trx = models.ForeignKey(Transaction, null=True)
- 
-    acct = models.ForeignKey(Account, null=True)
- 
-    job = models.ForeignKey(Job, null=True)
- 
-    clr = models.CharField(maxlength=80, null=True)
- 
-    memo = models.CharField(maxlength=80, null=True)
- 
-    subtot = models.FloatField(max_digits=10, decimal_places=2)
- 
-
-    class Admin:
-        pass
-
-
-class Payee(models.Model):
-    id = models.AutoField(primary_key=True)
- 
-    name = models.CharField(maxlength=80, null=True)
-
-    def __str__(self):
-        return self.name
- 
-
-    class Admin:
-        pass
-
-

File qfm/__init__.py

Empty file added.

File qfm/models.py

+from django.db import models
+
+class Account(models.Model):
+    id = models.AutoField(primary_key=True)
+ 
+    name = models.CharField(maxlength=80, null=True)
+
+    def __str__(self):
+        return self.name
+ 
+    parent = models.ForeignKey('self', null=True)
+ 
+
+    class Admin:
+        pass
+
+
+class Job(models.Model):
+    id = models.AutoField(primary_key=True)
+ 
+    name = models.CharField(maxlength=80, null=True)
+
+    def __str__(self):
+        return self.name
+ 
+
+    class Admin:
+        pass
+
+
+class Transaction(models.Model):
+    id = models.AutoField(primary_key=True)
+ 
+    acct = models.ForeignKey(Account, null=True)
+ 
+    date = models.DateField()
+ 
+    payee = models.CharField(maxlength=80, null=True)
+ 
+    num = models.CharField(maxlength=80, null=True)
+ 
+    ty = models.CharField(maxlength=80, null=True)
+ 
+    memo = models.CharField(maxlength=80, null=True)
+ 
+
+    class Admin:
+        pass
+
+
+class Split(models.Model):
+    id = models.AutoField(primary_key=True)
+ 
+    trx = models.ForeignKey(Transaction, null=True)
+ 
+    acct = models.ForeignKey(Account, null=True)
+ 
+    job = models.ForeignKey(Job, null=True)
+ 
+    clr = models.CharField(maxlength=80, null=True)
+ 
+    memo = models.CharField(maxlength=80, null=True)
+ 
+    subtot = models.FloatField(max_digits=10, decimal_places=2)
+ 
+
+    class Admin:
+        pass
+
+
+class Payee(models.Model):
+    id = models.AutoField(primary_key=True)
+ 
+    name = models.CharField(maxlength=80, null=True)
+
+    def __str__(self):
+        return self.name
+ 
+
+    class Admin:
+        pass
+
+

File qfm/templates/accounts.html

+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+  <title>Accounts</title>
+</head>
+<body>
+<ul>
+{% for a in accounts %}
+<li><a href="account/{a.id}">{{a.name}}</a></li>
+{% endfor %}
+</ul>
+
+<hr />
+<address>
+qfm by Dan Connolly Oct 2007
+</address>
+</body>
+</html>
+from django.conf.urls.defaults import * #@@ ew import *
+
+urlpatterns = patterns('',
+    (r'^accounts/', 'dm93data.qfm.views.accounts'),
+)

File qfm/views.py

+# based on
+# http://www.djangoproject.com/documentation/0.96/tutorial03/
+
+from django.shortcuts import render_to_response
+from dm93data.qfm.models import Account
+
+def accounts(request):
+    accounts = Account.objects.all().order_by('name')
+    return render_to_response('accounts.html',
+                              {'accounts': accounts})