Skip to content

Commit 80374e4

Browse files
committed
Typoes and spellings
1 parent ed975b4 commit 80374e4

File tree

7 files changed

+33
-19
lines changed

7 files changed

+33
-19
lines changed

source/contents.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Getting the docs
1212
----------------------
1313
The documents are generated using `Sphinx <http://sphinx.pocoo.org/>`_. The code
1414
is available on `Github <http://github.com/uswaretech/django-design-patterns/tree/master>`_.
15-
The generated Html is available on http://djangodesignpatterns.uswaretech.net/
15+
The generated Html is available on http://uswaretech.com/books/djangodesignpatterns/
1616

1717
License
1818
-------------

source/misc.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ out of settings.py into localsettings.py. In your settings.py, you should do::
1010
try:
1111
from localsettings import *
1212
except ImportError:
13-
print 'localsetting could not be imported'
13+
print 'localsettings could not be imported'
1414
pass #Or raise
1515

1616
This should be at the end of settings.py, so that localsetting.py override
@@ -41,7 +41,7 @@ the request to output this. Make it as a templatetag.
4141
Import as if your apps are on your project path
4242
----------------------------------------------------
4343
Instead of doing `from project.app.models import ModelClass` do `from app.models
44-
import ModelClass`. Your apps are reusable
44+
import ModelClass`. This makes you apps reusable as they are not tied to a project.
4545

4646
Naming things
4747
-----------------
@@ -56,12 +56,12 @@ and not::
5656
class Posts(models.Model):
5757
...
5858

59-
Foreign key should use the name of referenced class.::
59+
Foreign key should use the name of the referenced class.::
6060

6161
class Post(models.Model):
6262
user = models.ForeignKey(User)
6363

64-
Queryset should be plural, instances should be singular.::
64+
Querysets should be plural, instances should be singular.::
6565

6666
posts = Post.objects.all()
6767
posts = Post.objects.filter(...)
@@ -207,8 +207,8 @@ Have you handled all cases?
207207
...
208208

209209
Or it is? What about users created via `manage.py createsuperuser`, with the
210-
above middleware, the default user can not even access the admi site.
210+
above middleware, the default user can not even access the admin site.
211211

212212
Hence handle all scenarios in middleware and context processors. This is one place
213-
where `try: .. except: ..` (bare except) block are acceptable. You do not wnat one
214-
middleare bringing down entire site.
213+
where `try: .. except: ..` (bare except) blocks are acceptable. You do not want one
214+
middleare bringing down the entire site.

source/models.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ False in your Model).::
1919
all_objects = models.Manager()
2020
objects = ModelClassApprovedOnlyManager()
2121

22+
If you use multiple managers, the first manager should be the default manager. This is as the first
23+
manager is accesible as `ModelClass._default_manager`, which is used by admin to get all objects.
24+
2225
Hierarchical Relationships
2326
----------------------------
2427
You may want to model hierarchical relationships. The simplest way to do this is::
@@ -27,9 +30,9 @@ You may want to model hierarchical relationships. The simplest way to do this is
2730
...
2831
parent = models.ForeignKey('ModelClass')
2932

30-
This is called adjacency list model, is very inefficient for large trees. If you
33+
This is called adjacency list model, and is very inefficient for large trees. If your
3134
trees are very shallow you can use this. Otherwise you want to use a more
32-
complex modeling called MPTT. Fortunately, you can just use django-mptt.
35+
efficient but complex modeling called MPTT. Fortunately, you can just use django-mptt.
3336

3437
Singleton classes
3538
-------------------

source/templates.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ templates
44

55
Projects and apps.
66
--------------------
7-
There should be one base.html at the project level, and one base.html at each of
8-
the app levels. The app level base.html should extend the project level
7+
There should be one base.html at the project level, and one `base.html` at each of
8+
the app levels. The app level `base.html` should extend the project level
99
`base.html`.::
1010

1111
{# Eg Project base.html #}

source/urls.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Urls
55
Projects and apps
66
--------------------
77

8-
There should be one urls.py at the project level, and one urls.py at each app
9-
level. The project level urls.py should include each of the urls.py under a
8+
There should be one `urls.py` at the project level, and one `urls.py` at each app
9+
level. The project level `urls.py` should include each of the `urls.py` under a
1010
prefix.::
1111

1212
#project urls.py

source/views.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,22 @@ be posted on these objects, which this generic view does not allow.::
2929
Handle GET and POST in same view function
3030
----------------------------------------------
3131

32+
This keeps things grouped logically together. Eg.::
33+
34+
def foo(request):
35+
form = FormClass()
36+
if request.method == 'POST':
37+
#Handle post and form saving etv.
38+
#Redirect etc
39+
#Any more get handling
40+
payload = {'form': form, ...}
41+
return render_to_response(...)
42+
3243

3344
Querysets are chainable and lazy
3445
-----------------------------------
3546
This means that your view can keep on creating querysets and they would be
36-
evaluated onlly when used. Supposed when you have an advanced search view which
47+
evaluated only when used. Suppose you have an advanced search view which
3748
can take multiple criteria all of which are optional.::
3849

3950
def advanced_search(request, criteria1=None, criteria2=None, criteria3=None):

source/workflow.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ workflow
44

55
Use a source control system
66
-------------------------------
7-
Use SVN, GIT, Hg whavere. But choose one and use it.
7+
Use SVN, GIT, Hg whatever. But choose one and use it.
88

99
Use a bug tracking tool.
1010
----------------------------
11-
I recommend `Unfuddle <http://unfuddle.com/>`_, (It has various other niecties).
12-
But others might work for you.
11+
I recommend `Unfuddle <http://unfuddle.com/>`_, (It has various niceties, above a source control and bug tracking tool).
12+
But others might work for you. In particular Trac is free.
1313

1414
Use a schema migration tool
1515
------------------------------
@@ -18,7 +18,7 @@ south is propbably more popular.
1818

1919
Create various entries in your /etc/hosts mapped to localhost
2020
------------------------------------------------------------------
21-
While development you probably want various users logged in to the site
21+
While development you probably want multiple users logged in to the site
2222
simulataneously. For example, while developing, I have one user logged in the admin, one normal
2323
user using the site. If both try to access the site from localhost, one will be
2424
logged out when other logs in.

0 commit comments

Comments
 (0)