Skip to content

Commit

Permalink
Fixed several typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
kerwitz committed Apr 12, 2015
1 parent 4737937 commit 4b16240
Show file tree
Hide file tree
Showing 22 changed files with 57 additions and 64 deletions.
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ What's in there?


- "apps" : contains all the applications, sorted by complexity and requirements. This is what you want to read.
- "project": the django project itself, containing settings and the main url routes definition. You should have a look in there from time to time, it puts the apps in context and contains some tips.
- "libs": dependencies such as django or external libraries that you would have to install otherwise. You don't need to, but you can look into it once you start feeling confortable with Django.
- "project": the Django project itself, containing settings and the main URL routes definition. You should have a look in there from time to time, it puts the apps in context and contains some tips.
- "libs": dependencies such as Django or external libraries that you would have to install otherwise. You don't need to, but you can look into it once you start feeling comfortable with Django.
- "libs/ignore_me": the app that lists all the apps, and the main page of the project. You can ignore it, it's not very interesting.
- "manage.py": the command to interact with the Django project. This one is a bit modified so don't replace it.
- ".gitignore": a configuration file for git. You don't need this for Django. It's here to help me.
Expand All @@ -42,4 +42,4 @@ In a real project, you WOULD have to install something. Dependencies are provide

By the way, this is NOT a tutorial. The purpose is not to replace a full course about how Django works, but rather to give you a concrete example on how each task can be achieved with Django.

Translations and spell corrections welcome!
Translations and spell corrections welcome!
2 changes: 1 addition & 1 deletion apps/app1_hello/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Read views.py first.

Then template/home.html.

And enventually urls.py.
And eventually urls.py.
6 changes: 3 additions & 3 deletions apps/app1_hello/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

urlpatterns = patterns('',

# This says to django to call the function
# This says to Django to call the function
# 'home' in the module 'views' of the app 'app1_hello'" for any URL
url(r'', 'app1_hello.views.hello'),

)


# This url pattern is included in project/urls.py, this is why it works.
# You will want to read this file to understand url routing better.
# This URL pattern is included in project/urls.py, this is why it works.
# You will want to read this file to understand URL routing better.
14 changes: 6 additions & 8 deletions apps/app1_hello/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ def hello(request):
# hello() is a simple function that MUST accept an HTTP request an return a #
# response. #
# #
# This function is called automatically when the url in the urls.py file that #
# This function is called automatically when the URL in the urls.py file that #
# point to it is reached. #
# #
# The request object is passed automatically by Django, and we can do whatever #
# we want in the fonction body. #
# we want in the function body. #
# #
# The only obligation from our part is to return a HTTP response, which we do by #
# returning the result of render(), which build the reponse for us from the #
# returning the result of render(), which build the response for us from the #
# initial request, a template name and a template context. #
# #
# The template name will be the name of the file we want to use to format our #
# data. In this cas, "hello.html" contains just a bit of HTML. You can #
# data. In this case, "hello.html" contains just a bit of HTML. You can #
# find it in the "templates" directory of this app. #
# #
# The last parameter is the template context, a dictionry of variables we wish #
# to be available to use in the template. Here we pass the valud "world" and we #
# The last parameter is the template context, a dictionary of variables we wish #
# to be available to use in the template. Here we pass the value "world" and we #
# give it the name "name" so in the template, you can use the variable "name" to #
# display its content. #
# #
Expand All @@ -40,5 +40,3 @@ def hello(request):
# models are the ORM classes, but the views are the functions in the views.py, #
# not the templates. #
# ################################################################################


4 changes: 2 additions & 2 deletions apps/app2_hello_again/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ It's the same as the previous app, but the response is constructed manually, ste

You usually won't use this in your own code, but it's useful to see how it works.

First got to urls.py to see an alternative way to map a url to a view.
First got to urls.py to see an alternative way to map a URL to a view.

Then go to views.py to see the detailed way of building a response.
Then go to views.py to see the detailed way of building a response.
2 changes: 1 addition & 1 deletion apps/app2_hello_again/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.conf.urls import patterns, url


# an alternative way of mapping a url to a view is to pass directly the
# an alternative way of mapping a URL to a view is to pass directly the
# imported view (and not a string, like in app1)
from app2_hello_again.views import hello

Expand Down
3 changes: 2 additions & 1 deletion apps/app3_basic_routing/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ How to get values from the URL as variables in your view functions.

Check out views.py, then urls.py and eventually all templates.

REMEMBER : there are a lot of comments but actuelly little code. Try to remove comments and docstrings from a file to have a good view of what it really contains. You will be surprised.
REMEMBER : there are a lot of comments but actually little code. Try to remove comments and docstrings
from a file to have a good view of what it really contains. You will be surprised.
4 changes: 2 additions & 2 deletions apps/app3_basic_routing/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

"""
"routing" is declaring what url will trigger which vue function to be
"routing" is declaring what URL will trigger which vue function to be
called.
"""

Expand Down Expand Up @@ -31,7 +31,7 @@
# - (?P<name>\w+) will match any set of letters and _ then capture it
# under the name of "name" to pass it as a parameter to hello()
# - (?P<prefix>\w+) will match any additional set of letters and _, after
# the first slash, catpure is under the name "prefix" to pass it as
# the first slash, capture is under the name "prefix" to pass it as
# a parameter to hello().
#
# This syntax is not specific to Django, it's plain old regular expressions
Expand Down
3 changes: 1 addition & 2 deletions apps/app3_basic_routing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- one main view at the root of the app URL pattern
- one static view with a prefix
- one dynamic view with url parameter
- one dynamic view with URL parameter
"""


Expand Down Expand Up @@ -47,4 +47,3 @@ def hello(request, name, prefix="hello"):
}

return render(request, 'hello3.html', context)

3 changes: 1 addition & 2 deletions apps/app4_links/templates/app4_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<h1>Links</h1>


<p>This is the same as the previous app, but we generate them dynamically. Try these links :</p>
<p>This is the same as the previous app, but we generate them dynamically. Try these links:</p>

<ul>
<li>
Expand Down Expand Up @@ -83,4 +83,3 @@ <h1>Links</h1>

</body>
</html>

2 changes: 1 addition & 1 deletion apps/app4_links/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
When you start having a lot of routes, you can give them names, and
refer to this name later, when you want a link for them.
Here we will use the SAME urls and views as in the previous app,
Here we will use the SAME URLs and views as in the previous app,
but we will give them names.
"""

Expand Down
3 changes: 2 additions & 1 deletion apps/app6_template_tools/README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Format things using filters, add some logic using tags, and reuse bits of template using inheritance and includes.

Almost everything interessting are in the templates, but you may want to have a quick look a the views to gather some context. Also, there is a little trick in urls.py.
Almost everything interesting are in the templates, but you may want to have a quick look a the views
to gather some context. Also, there is a little trick in urls.py.
3 changes: 1 addition & 2 deletions apps/app6_template_tools/templates/app6_includes.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ <h1>Template includes</h1>
{% include 'app6_included.html' %}
</div>

<p>WARNING : the included template and the including template are rendered separatly, THEN merged. This means you can't access variables from one in another. If you need to do so, use <code>with</code> :</p>
<p>WARNING: the included template and the including template are rendered separatly, THEN merged. This means you can't access variables from one in another. If you need to do so, use <code>with</code> :</p>

<code>{ % include 'app6_included.html' with variable=value % }</code>

<p>Includes and inheritance can be used together without any problem.</p>

</body>
</html>

3 changes: 1 addition & 2 deletions apps/app6_template_tools/templates/app6_tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h1>Template tags</h1>
{% endfor %}
</dl>
</td>
<td><p>If you need to use a <code>[]</code>, just use a dot. <code>team['A']</code> becomes <code>team.A</code> and <code>team['A'][0]</code> becomes <code>team.A.0</code>. You also have access to a variable named <code>forloop</code> automatically created by Django in any <code>for</code> block. Its attributes contains useful informations such as :</p>
<td><p>If you need to use a <code>[]</code>, just use a dot. <code>team['A']</code> becomes <code>team.A</code> and <code>team['A'][0]</code> becomes <code>team.A.0</code>. You also have access to a variable named <code>forloop</code> automatically created by Django in any <code>for</code> block. Its attributes contains useful informations such as:</p>
<ul><li><code>forloop.counter</code>: a 1-indexed counter</li>
<li><code>forloop.first</code>: <code>True</code> if <code>forloop.counter == 1</code></li>
<li><code>forloop.last</code>: <code>True</code> if we are at the last element of the loop</li>
Expand Down Expand Up @@ -195,4 +195,3 @@ <h1>Template tags</h1>

</body>
</html>

2 changes: 1 addition & 1 deletion apps/app6_template_tools/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# and provided by Django. There are a lot of them to do various tasks,
# usually for stuff you do very often.
# TemplateView is also a class based view, while you have been using
# only functions to create views untill now.
# only functions to create views until now.
# Don't worry about it.
# You just need to know that TemplateView allow you to render a template
# directly with this syntax, without the need to code a empty view
Expand Down
4 changes: 2 additions & 2 deletions apps/app6_template_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def filters(request):
# filter: truncatewords
context['phrase'] = '''
A very very very long phrase that we shall truncate so it doesn't get
to long to read or mess up the layout of our beloved and wonderlful
to long to read or mess up the layout of our beloved and wonderful
website. Did I mentioned I love platipus ?
'''

Expand Down Expand Up @@ -90,4 +90,4 @@ def inheritance(request):


def includes(request):
return render(request, 'app6_includes.html')
return render(request, 'app6_includes.html')
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Just like with template, you can create directories and subdirectories
to organize you files.

E.G : you could put this in app7_static_file/css/style.css.
E.G: you could put this in app7_static_file/css/style.css.

Just like with templates, another app can override the static files
from this app by using the same path and name.
Expand Down Expand Up @@ -57,4 +57,3 @@ <h1>Basics</h1>

</body>
</html>

Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ <h2>Put all static files in the same dir</h2>

<h2>Serve static files</h2>

<p>It will be then your job to create a configuration file for your server so it serves the content of <code>settings.STATIC_ROOT</code> when a request is made to <code>settings.STATIC_URL</code> (currently : <em>{{ settings.STATIC_URL }}</em>)</p>
<p>It will be then your job to create a configuration file for your server so it serves the content of <code>settings.STATIC_ROOT</code> when a request is made to <code>settings.STATIC_URL</code> (currently: <em>{{ settings.STATIC_URL }}</em>)</p>

<p>I like to use Nginx to serve Django apps. Here is what a minimalist Nginx configuration file could look like :</p>
<p>I like to use Nginx to serve Django apps. Here is what a minimalist Nginx configuration file could look like:</p>

<pre>
server {
Expand Down
4 changes: 2 additions & 2 deletions apps/app8_base/README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
We are going to use this app in other future apps to avoid coding again and again the same features.

This app provides some interesting items : a base template, an index template and a index view. It also brings some default CSS.
This app provides some interesting items: a base template, an index template and a index view. It also brings some default CSS.

This is an occasion for you to discover what makes a code reusable in Django.
This is an occasion for you to discover what makes a code reusable in Django.
4 changes: 2 additions & 2 deletions project/README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"settings.py" contains the settings for your Django project. It's an ordinary Python module you can import and use like any other modules.

"urls.py "contains code that associate urls with apps, so when a user go to your website on a specific url, the code of the right app is used.
"urls.py "contains code that associate URLs with apps, so when a user go to your website on a specific URL, the code of the right app is used.

"wsgi.py" is only used in production and you can ignore it. However, you can't delete it as it became mandatory in the last Django release.
"wsgi.py" is only used in production and you can ignore it. However, you can't delete it as it became mandatory in the last Django release.
13 changes: 6 additions & 7 deletions project/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


"""
This module contains all the paths for alls this project directories, that
This module contains all the paths for directories of this project that
we created dynamically.
All paths are absolute, without symlink and in unicode.
Expand All @@ -20,18 +20,18 @@
import tempfile

# This part is a bit complicated and is not mandatory for your project, but
# it renders it completly portable since all directory paths are dyncamically
# it renders it completely portable since all directory paths are dynamically
# generated instead of being hard coded.

# We get the 'settings.py' file path (the __FILE__ variable contains
# automatically the path of the current file) and we transform this string
# in unicode in case you got non ASCII caracters in this name (
# sys.getfilesystemencoding() git us the file system encoding which can be
# in unicode in case you got non ASCII characters in this name (
# sys.getfilesystemencoding() git use the file system encoding which can be
# different for Windows, Mac or Linux)
FS_ENCODING = sys.getfilesystemencoding()
try:
THIS_FILE = __file__.decode(FS_ENCODING)
except AttributeError:
except AttributeError:
# In Python 3, __file__ is already decoded
THIS_FILE = __file__

Expand All @@ -45,7 +45,7 @@

try:
TEMP_DIR = tempfile.gettempdir().decode(FS_ENCODING)
except AttributeError:
except AttributeError:
# In Python 3, __file__ is already decoded
TEMP_DIR = tempfile.gettempdir()

Expand All @@ -64,4 +64,3 @@
# thing to know.
sys.path.append(LIBS_DIR)
sys.path.append(APPS_DIR)

29 changes: 14 additions & 15 deletions project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# automatically when you do "django-admin.py startproject". #
# #
# Most values are Django settings, erasing the default values you can find in #
# libs/django/conf/global_settings.py. A lot of original Django settings arez #
# libs/django/conf/global_settings.py. A lot of original Django settings are #
# not changed so you'll have to refer to global_settings.py to know their #
# value. #
# #
Expand All @@ -20,9 +20,9 @@
# NOTE: the scope of this project is to show you how to do things in apps, #
# not how to deploy Django. Therefor the settings content and layout fit #
# this purpose and do not reflect how a production site should do it. #
# I will specifically put a note when warning applys, and the first #
# I will specifically put a note when warning applies, and the first #
# warning is: "You should have several settings files in a real project #
# to seperate production, staging and developpement environnements" #
# to separate production, staging and development environments" #
# #
###############################################################################

Expand All @@ -36,7 +36,7 @@
import os

# We get the path of all this directories from the "path" module. The path.py
# file is something we code ourself, it's not provided by Django, but it's
# file is something we code ourselves, it's not provided by Django, but it's
# very useful to avoid hard coding all these paths.
from project.path import PROJECT_DIR, ROOT_DIR, TEMP_DIR, APPS_DIR

Expand Down Expand Up @@ -78,12 +78,12 @@


# You can choose the timezone you site will be set to. If you set it to None,
# it will be set to your machine time zone. It recommand this settings, but
# it will be set to your machine time zone. It recommend this settings, but
# on the strict condition your server time zone is set to UTC (which it should).
TIME_ZONE = None

# Unless you plan to do a site in your own langage only (in which case you
# would benefit from default formatting for time, date, monney, etc), you should
# Unless you plan to do a site in your own language only (in which case you
# would benefit from default formatting for time, date, money, etc), you should
# let this default value and translate later.
LANGUAGE_CODE = 'en-us'

Expand All @@ -92,12 +92,12 @@
# it by one for each site. Usually you just need to let that alone.
SITE_ID = 1

# Do you want your text to be translatable in other langages ?
# If you don't, set it to False to gain some perf.
# Do you want your text to be translatable in other languages ?
# If you don't, set it to False to gain some performance.
USE_I18N = True

# Do you want Django to translate dates, monney and numbers according to the
# locale ? If you don't, set it to False to gain some perf.
# Do you want Django to translate dates, money and numbers according to the
# locale ? If you don't, set it to False to gain some performance.
USE_L10N = True

# True by default. Set it to False. Store everything as UTC and deal with
Expand Down Expand Up @@ -164,7 +164,7 @@
# 'django.template.loaders.eggs.Loader',
)

# Middleware are the Django mecanisme to apply a process to every request.
# Middleware are the Django mechanism to apply a process to every request.
# These are the default ones, but you can write your own. You don't need
# too fiddle with middleware very often.
MIDDLEWARE_CLASSES = (
Expand All @@ -177,8 +177,8 @@
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

# The python import path to the main urls module. This is where you declare
# the root of all your urls for all your apps
# The python import path to the main URLs module. This is where you declare
# the root of all your URLs for all your apps
ROOT_URLCONF = 'project.urls'

# Python dotted path to the WSGI application used by Django's runserver.
Expand Down Expand Up @@ -293,4 +293,3 @@
#################################################################################

# NONE YET

0 comments on commit 4b16240

Please sign in to comment.