BibleFeed Project: Creating the models
This is the second post relating to the BibleFeed Project. If you haven’t yet, you may want to read the first post.
As with most applications, this one needs to store data. To store data in a django project, I need to first create models representing the data. While I’m sure that the following will not be everything, this is good enough to start with:
TESTAMENTS = (
('O','Old Testament'),
('N','New Testament'),
)
name = models.CharField(max_length=50)
testament = models.CharField(max_length=1, choices=TESTAMENTS)
class Chapter(models.Model):
book = models.ForeignKey(Book)
chapter_num = models.IntegerField()
class Verse(models.Model):
chapter = models.ForeignKey(Chapter)
text = models.TextField()
verse_num = models.IntegerField()
These models are straightforward. There is a Book class which will store the name of book and which testament it is part of. The Chapter class has a field storing which book it is part of, and a field for the chapter number. The Verse class points to the chapter that contains it and has fields for the text of the verse and the verse number.
Now I need to have somewhere to store the data now that I have the models to represent it. Before I do that though, I need to let django know it should include the BibleFeed application. I edit the INSTALLED_APPS setting in the settings.py field:
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'biblefeed.bible',
)
Now I can run the syncdb command which will create the database tables.
Creating table bible_book
Creating table bible_chapter
Creating table bible_verse
Installing index for bible.Chapter model
Installing index for bible.Verse model
I realize at this point I haven’t shown anything too exciting, and there’s not much that is interactive here, unless you really enjoy viewing the tables in the database. The next post will create something a little more interactive.
January 29th, 2009 at 7:04 am
Just an idea, but you may want to expand to allow for the Apocrypha. They aren’t considered Christian canon, but I think most Bible readers would have at least a peripheral interest in those books. You’d want to mark them clearly as Apocryphal if you did of course. You could have checkboxes or something to turn them on or off at the RSS subscribe stage. Or maybe just make a separate ApocryphaFeed later. Anyway, just thought I’d throw that out there.
January 29th, 2009 at 11:11 am
For this project I was intending to keep it simple, but in the future there’s no reason I couldn’t add a feed for Apocryphal texts.