http://docs.djangoproject.com/en/dev/topics/db/models/
Each table in your database is modeled using a class in Python. Django sets up an empty “models.py” file that you should use for these models. We’ll set up a very basic blog in models.py. It will have posts, authors, and topics.
The first thing you need to do is create an app. An app is a collection of related models. Our tutorial Blog will only have one app, “postings”.
python manage.py startapp postings
This creates a new folder, postings, with models.py and views.py, among other files.
- Create your models: Posts
- The basic unit of our blog is the post. Each post has a title, some content, the date it was published, whether or not it is public, some topics, an author, and when it was last edited.
- Create your models: Authors
- Above the Post model, add an Author model. It has to be above the Post model, because the Post model references it as a ForeignKey.
- Create your models: Topics
- Above the Post model, add a Topic model.
- Synchronize your database
- Once you’ve got the model designed, add “Blog.postings” to settings.py. Add another line to the list of INSTALLED_APPS: