On 27/08/2017 12:45 AM, Derek wrote:
> Mike
>
> Not sure what your github skill level is;
Long ago I once set up a github repo but lost my certificate when my
laptop died and there it ended. I manage a number of subversion
repositories for a number of people and all my dev is based on svn so I
don't really have the brainspace for git as well. Anyway, git is
probably just a passing fad.
OK - best effort here. I used svn to adjust that file and create a patch
in (I believe) git format. It really needs to be reviewed by a Django
beginner as well as a guru ... see below.
Index: tutorial01.txt
===================================================================
diff --git a/doc/tutorial01.txt b/doc/tutorial01.txt
--- a/doc/tutorial01.txt (revision 0)
+++ b/doc/tutorial01.txt (working copy)
@@ -235,7 +235,7 @@
tests.py
views.py
-This directory structure will house the poll application.
+This directory structure will house the polls application.
Write your first view
=====================
@@ -255,7 +255,7 @@
This is the simplest view possible in Django. To call the view, we
need to map
it to a URL - and for this we need a URLconf.
-To create a URLconf in the polls directory, create a file called
``urls.py``.
+To create a URLconf in the polls directory, create a new file called
``urls.py``.
Your app directory should now look like::
polls/
@@ -282,10 +282,31 @@
url(r'^$', views.index, name='index'),
]
-The next step is to point the root URLconf at the ``polls.urls`` module. In
-``mysite/urls.py``, add an import for ``django.conf.urls.include`` and
insert
-an :func:`~django.conf.urls.include` in the ``urlpatterns`` list, so
you have:
+The next step is to point the project URLconf at the ``polls.urls`` module.
+.. admonition:: Project urls.py vs. app urls.py vs. views.py
+
+ Your project has a project urls.py file ``mysite/mysite/urls.py``
(Recall
+ that this was automatically created when you issued the command ``$``
+ django-admin startproject mysite). It contains URLconfs. When a browser
+ requests a URL, it needs to trigger some software to make something
happen.
+ Such software is known in Django as a view.
+
+ You have just written your first view in views.py in the polls
application
+ directory. It must be mapped to the outside world via a URLconf.
+
+ While it is possible we don't want to use the project urls.py file,
already
+ mentioned, for all the individual polls app URLs. There might be
many of
+ them. And eventually, the project (or package) may contain many
apps. The
+ polls app really needs its own urls.py for its own URLconfs and we just
+ include them in the project urls.py with a single reference. The
bonus is
+ you can easily re-use the polls app in other projects.
+
+
+In the existing ``mysite/mysite/urls.py``, add an import for
+``django.conf.urls.include`` and insert an
:func:`~django.conf.urls.include` in
+the ``urlpatterns`` list, so you have:
+
.. snippet::
:filename: mysite/urls.py
Cheers
Mike
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
django-users...@googlegroups.com
> <mailto:
django-users...@googlegroups.com>.
> To post to this group, send email to
django...@googlegroups.com
> <mailto:
django...@googlegroups.com>.
> Visit this group at
https://groups.google.com/group/django-users.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/django-users/7ae8d6e4-0760-4441-8a5a-e8bcdd9e0d0c%40googlegroups.com
> <
https://groups.google.com/d/msgid/django-users/7ae8d6e4-0760-4441-8a5a-e8bcdd9e0d0c%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit
https://groups.google.com/d/optout.