2011年5月4日 星期三

create first model

1.modify models.py to add new model link

from django.db import models
# Create your models here.
class Link( models.Model ):
url = models.URLField( unique = True )

2.use sql syntax to see create table
#python manage sql bookmarks

3.create table
#python manage syncdb

4.use shell to create records
#python manage shell
from bookmarks.model import *
link1 = Link(url="http://www.google.com.tw")
link1.save()
link2 = Link(url="http://tw.yahoo.com")
link2.save

沒有留言:

張貼留言