Search This Blog

Monday, September 21, 2009

Django, Create Your Model

python manage.py startapp my_model
my_model/model.py

settings.py
INSTALLED_APPS
-->mysite.my_model

python manage.py sql my_model
(check the actual sql statements)

python manage.py syncdb
(really create the database)

python manage.py shell
>>
i = idea(title="Butterfly", description="sell butterfly", author="Jie", date=datetime.datetime.now())


To use your model in views.py and admin.py, just import your model class from your model.

No comments: