Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed small typo in overview

git-svn-id: http://code.djangoproject.com/svn/django/trunk@90 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 07c8a965b675ae7b3047c60f2f156a8840de6c8b 1 parent 8d0610d
Adrian Holovaty authored July 16, 2005

Showing 1 changed file with 24 additions and 24 deletions. Show diff stats Hide diff stats

  1. 48  docs/overview.txt
48  docs/overview.txt
@@ -24,10 +24,10 @@ solving two years' worth of database-schema problems. Here's a quick example::
24 24
         fields = (
25 25
             meta.CharField('full_name', "reporter's full name", maxlength=70),
26 26
         )
27  
-    
  27
+
28 28
         def __repr__(self):
29 29
             return self.full_name
30  
-    
  30
+
31 31
     class Article(meta.Model):
32 32
         fields = (
33 33
             meta.DateTimeField('pub_date', 'publication date'),
@@ -35,7 +35,7 @@ solving two years' worth of database-schema problems. Here's a quick example::
35 35
             meta.TextField('article', 'article'),
36 36
             meta.ForeignKey(Reporter),
37 37
         )
38  
-    
  38
+
39 39
         def __repr__(self):
40 40
             return self.headline
41 41
 
@@ -58,29 +58,29 @@ is created on the fly: No code generation necessary::
58 58
     # Modules are dynamically created within django.models.
59 59
     # Their names are plural versions of the model class names.
60 60
     >>> from django.models.news import reporters, articles
61  
-    
  61
+
62 62
     # No reporters are in the system yet.
63 63
     >>> reporters.get_list()
64 64
     []
65  
-    
  65
+
66 66
     # Create a new Reporter.
67 67
     >>> r = reporters.Reporter(id=None, full_name='John Smith')
68  
-    
  68
+
69 69
     # Save the object into the database. You have to call save() explicitly.
70 70
     >>> r.save()
71  
-    
  71
+
72 72
     # Now it has an ID.
73 73
     >>> r.id
74 74
     1
75  
-    
  75
+
76 76
     # Now the new reporter is in the database.
77 77
     >>> reporters.get_list()
78 78
     [John Smith]
79  
-    
  79
+
80 80
     # Fields are represented as attributes on the Python object.
81 81
     >>> r.full_name
82 82
     'John Smith'
83  
-    
  83
+
84 84
     # Django provides a rich database lookup API that's entirely driven by keyword arguments.
85 85
     >>> reporters.get_object(id__exact=1)
86 86
     John Smith
@@ -91,35 +91,35 @@ is created on the fly: No code generation necessary::
91 91
     >>> reporters.get_object(id__exact=2)
92 92
     Traceback (most recent call last):
93 93
         ...
94  
-    django.models.polls.ReporterDoesNotExist: Reporter does not exist for {'id__exact': 2}
95  
-    
  94
+    django.models.news.ReporterDoesNotExist: Reporter does not exist for {'id__exact': 2}
  95
+
96 96
     # Create an article.
97 97
     >>> from datetime import datetime
98 98
     >>> a = articles.Article(id=None, pub_date=datetime.now(), headline='Django is cool', article='Yeah.', reporter_id=1)
99 99
     >>> a.save()
100  
-    
  100
+
101 101
     # Now the article is in the database.
102 102
     >>> articles.get_list()
103 103
     [Django is cool]
104  
-    
  104
+
105 105
     # Article objects get API access to related Reporter objects.
106 106
     >>> r = a.get_reporter()
107 107
     >>> r.full_name
108 108
     'John Smith'
109  
-    
  109
+
110 110
     # And vice versa: Reporter objects get API access to Article objects.
111 111
     >>> r.get_article_list()
112 112
     [Django is cool]
113  
-    
  113
+
114 114
     # The API follows relationships as far as you need.
115 115
     # Find all articles by a reporter whose name starts with "John".
116 116
     >>> articles.get_list(reporter__full_name__startswith="John")
117 117
     [Django is cool]
118  
-    
  118
+
119 119
     # Change an object by altering its attributes and calling save().
120 120
     >>> r.full_name = 'Billy Goat'
121 121
     >>> r.save()
122  
-    
  122
+
123 123
     # Delete an object with delete().
124 124
     >>> r.delete()
125 125
 
@@ -167,7 +167,7 @@ To design URLs for an app, you create a Python module. For the above
167 167
 Reporter/Article example, here's what that might look like::
168 168
 
169 169
     from django.conf.urls.defaults import *
170  
-    
  170
+
171 171
     urlpatterns = patterns('',
172 172
         (r'^/articles/(?P\d{4})/$',                   'myproject.news.views.articles.year_archive'),
173 173
         (r'^/articles/(?P\d{4})/(?P\d{2})/$',         'myproject.news.views.articles.month_archive'),
@@ -205,7 +205,7 @@ and renders the template with the retrieved data. Here's an example view for
205 205
 article_detail from above::
206 206
 
207 207
     from django.models.news import articles
208  
-    
  208
+
209 209
     def article_detail(request, year, month, article_id):
210 210
         # Use the Django API to find an object matching the URL criteria.
211 211
         try:
@@ -235,9 +235,9 @@ Let's say the ``news/article_detail`` template was found. Here's what that might
235 235
 look like::
236 236
 
237 237
     {% extends "base" %}
238  
-    
  238
+
239 239
     {% block title %}{{ article.headline }}{% endblock %}
240  
-    
  240
+
241 241
     {% block content %}
242 242
     <h1>{{ article.headline }}</h1>
243 243
     <p>By {{ article.get_reporter.full_name }}</p>
@@ -270,7 +270,7 @@ template has to define only what's unique to that template.
270 270
 
271 271
 Here's what the "base" template might look like::
272 272
 
273  
-    
  273
+
274 274
     <html>
275 275
     <head>
276 276
         <title>{% block title %}</title>
@@ -300,7 +300,7 @@ This has been only a quick overview of Django's functionality. Some more useful
300 300
 features:
301 301
 
302 302
     * A caching framework that integrates with memcached or other backends.
303  
-    * An RSS framework that makes creating RSS feeds as easy as writing a 
  303
+    * An RSS framework that makes creating RSS feeds as easy as writing a
304 304
       small Python class.
305 305
     * More sexy automatically-generated admin features -- this overview barely
306 306
       scratched the surface

0 notes on commit 07c8a96

Please sign in to comment.
Something went wrong with that request. Please try again.