mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
@@ -31,7 +31,7 @@ the file ``mysite/news/models.py``::
|
||||
return self.full_name
|
||||
|
||||
class Article(models.Model):
|
||||
pub_date = models.DateTimeField()
|
||||
pub_date = models.DateField()
|
||||
headline = models.CharField(max_length=200)
|
||||
content = models.TextField()
|
||||
reporter = models.ForeignKey(Reporter)
|
||||
@@ -96,8 +96,8 @@ access your data. The API is created on the fly, no code generation necessary::
|
||||
DoesNotExist: Reporter matching query does not exist. Lookup parameters were {'id': 2}
|
||||
|
||||
# Create an article.
|
||||
>>> from datetime import datetime
|
||||
>>> a = Article(pub_date=datetime.now(), headline='Django is cool',
|
||||
>>> from datetime import date
|
||||
>>> a = Article(pub_date=date.today(), headline='Django is cool',
|
||||
... content='Yeah.', reporter=r)
|
||||
>>> a.save()
|
||||
|
||||
@@ -140,7 +140,7 @@ as registering your model in the admin site::
|
||||
from django.db import models
|
||||
|
||||
class Article(models.Model):
|
||||
pub_date = models.DateTimeField()
|
||||
pub_date = models.DateField()
|
||||
headline = models.CharField(max_length=200)
|
||||
content = models.TextField()
|
||||
reporter = models.ForeignKey(Reporter)
|
||||
|
||||
Reference in New Issue
Block a user