From 00d5e632fabc03a0633b9910605b23bcec439cdc Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Sat, 28 Jul 2012 13:17:33 -0400 Subject: Fixed #18630 -- Updated version in docs/intro/install.txt; thanks Kevin London. --- docs/intro/install.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docs/intro') diff --git a/docs/intro/install.txt b/docs/intro/install.txt index 7e8c7db7b3..70c8034c5d 100644 --- a/docs/intro/install.txt +++ b/docs/intro/install.txt @@ -84,8 +84,9 @@ Then at the Python prompt, try to import Django:: >>> import django >>> print(django.get_version()) - 1.4 + 1.5 +You may have another version of Django installed. That's it! ---------- -- cgit v1.3 From 690ed5794672495e4cffca9a4a701008d254a4e7 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Sun, 29 Jul 2012 18:14:26 -0400 Subject: Fixed #18476 - Added use of {% url %} tag to tutorial. Thanks Claude Paroz for the patch. --- docs/intro/tutorial03.txt | 17 +++++++++++++++++ docs/intro/tutorial04.txt | 23 ++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) (limited to 'docs/intro') diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt index fd3a04ba93..d15b2f43ae 100644 --- a/docs/intro/tutorial03.txt +++ b/docs/intro/tutorial03.txt @@ -533,5 +533,22 @@ under "/content/polls/", or any other path root, and the app will still work. All the poll app cares about is its relative path, not its absolute path. +Removing hardcoded URLs in templates +------------------------------------ + +Remember, when we wrote the link to a poll in our template, the link was +partially hardcoded like this: + +.. code-block:: html+django + +
  • {{ poll.question }}
  • + +To use the decoupled URLs we've just introduced, replace the hardcoded link +with the :ttag:`url` template tag: + +.. code-block:: html+django + +
  • {{ poll.question }}
  • + When you're comfortable with writing views, read :doc:`part 4 of this tutorial ` to learn about simple form processing and generic views. diff --git a/docs/intro/tutorial04.txt b/docs/intro/tutorial04.txt index 44b9c16c2a..31680ea5e5 100644 --- a/docs/intro/tutorial04.txt +++ b/docs/intro/tutorial04.txt @@ -18,7 +18,7 @@ tutorial, so that the template contains an HTML ``
    `` element: {% if error_message %}

    {{ error_message }}

    {% endif %} - + {% csrf_token %} {% for choice in poll.choice_set.all %} @@ -35,7 +35,7 @@ A quick rundown: selects one of the radio buttons and submits the form, it'll send the POST data ``choice=3``. This is HTML Forms 101. -* We set the form's ``action`` to ``/polls/{{ poll.id }}/vote/``, and we +* We set the form's ``action`` to ``{% url 'polls.views.vote' poll.id %}``, and we set ``method="post"``. Using ``method="post"`` (as opposed to ``method="get"``) is very important, because the act of submitting this form will alter data server-side. Whenever you create a form that alters @@ -172,7 +172,7 @@ Now, create a ``results.html`` template: {% endfor %} - Vote again? + Vote again? Now, go to ``/polls/1/`` in your browser and vote in the poll. You should see a results page that gets updated each time you vote. If you submit the form @@ -238,11 +238,13 @@ Change it like so:: ListView.as_view( queryset=Poll.objects.order_by('-pub_date')[:5], context_object_name='latest_poll_list', - template_name='polls/index.html')), + template_name='polls/index.html'), + name='poll_index'), url(r'^(?P\d+)/$', DetailView.as_view( model=Poll, - template_name='polls/detail.html')), + template_name='polls/detail.html'), + name='poll_detail'), url(r'^(?P\d+)/results/$', DetailView.as_view( model=Poll, @@ -265,8 +267,8 @@ two views abstract the concepts of "display a list of objects" and ``"pk"``, so we've changed ``poll_id`` to ``pk`` for the generic views. -* We've added a name, ``poll_results``, to the results view so - that we have a way to refer to its URL later on (see the +* We've added the ``name`` argument to the views (e.g. ``name='poll_results'``) + so that we have a way to refer to their URL later on (see the documentation about :ref:`naming URL patterns ` for information). We're also using the :func:`~django.conf.urls.url` function from @@ -317,6 +319,13 @@ function anymore -- generic views can be (and are) used multiple times return HttpResponseRedirect(reverse('poll_results', args=(p.id,))) +The same rule apply for the :ttag:`url` template tag. For example in the +``results.html`` template: + +.. code-block:: html+django + + Vote again? + Run the server, and use your new polling app based on generic views. For full details on generic views, see the :doc:`generic views documentation -- cgit v1.3 From 2a16eb07927c866b4d8e1d318f71bd1038b34cae Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 2 Aug 2012 19:21:48 -0400 Subject: Fixed #17704 - Updated the StackedInline section in Tutorial 2; thanks xbito for the draft patch. --- docs/intro/_images/admin15t.png | Bin 0 -> 22805 bytes docs/intro/tutorial02.txt | 8 ++++++++ 2 files changed, 8 insertions(+) create mode 100644 docs/intro/_images/admin15t.png (limited to 'docs/intro') diff --git a/docs/intro/_images/admin15t.png b/docs/intro/_images/admin15t.png new file mode 100644 index 0000000000..999d0519fb Binary files /dev/null and b/docs/intro/_images/admin15t.png differ diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt index 84da36be86..fd13230c8b 100644 --- a/docs/intro/tutorial02.txt +++ b/docs/intro/tutorial02.txt @@ -311,6 +311,14 @@ It works like this: There are three slots for related Choices -- as specified by ``extra`` -- and each time you come back to the "Change" page for an already-created object, you get another three extra slots. +At the end of the three current slots you will find an "Add another Choice" +link. If you click on it, a new slot will be added. If you want to remove the +added slot, you can click on the X to the top right of the added slot. Note +that you can't remove the original three slots. This image shows an added slot: + +.. image:: _images/admin15t.png + :alt: Additional slot added dynamically + One small problem, though. It takes a lot of screen space to display all the fields for entering related ``Choice`` objects. For that reason, Django offers a tabular way of displaying inline related objects; you just need to change -- cgit v1.3 From 5d4f993bb1f01c3a79194031827380dc763ce628 Mon Sep 17 00:00:00 2001 From: Angeline Tan Date: Sat, 4 Aug 2012 15:05:57 -0700 Subject: Moved a note about django-admin.py errors from Tutorial Part 1 to a new FAQ Troubleshooting page. This is to avoid confusion for beginners. --- docs/faq/index.txt | 3 ++- docs/faq/troubleshooting.txt | 16 ++++++++++++++++ docs/intro/tutorial01.txt | 10 ++-------- 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 docs/faq/troubleshooting.txt (limited to 'docs/intro') diff --git a/docs/faq/index.txt b/docs/faq/index.txt index 347cabaabc..b7281946ee 100644 --- a/docs/faq/index.txt +++ b/docs/faq/index.txt @@ -11,4 +11,5 @@ Django FAQ help models admin - contributing \ No newline at end of file + contributing + troubleshooting \ No newline at end of file diff --git a/docs/faq/troubleshooting.txt b/docs/faq/troubleshooting.txt new file mode 100644 index 0000000000..f984be4bf5 --- /dev/null +++ b/docs/faq/troubleshooting.txt @@ -0,0 +1,16 @@ +=============== +Troubleshooting +=============== + +This page contains some advice about errors and problems commonly encountered +during the development of Django applications. + +"command not found: django-admin.py" +------------------------------------ + +:doc:`django-admin.py ` should be on your system path if you +installed Django via ``python setup.py``. If it's not on your path, you can +find it in ``site-packages/django/bin``, where ``site-packages`` is a directory +within your Python installation. Consider symlinking to :doc:`django-admin.py +` from some place on your path, such as +:file:`/usr/local/bin`. \ No newline at end of file diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt index 250c0f1f41..1e2231d1e0 100644 --- a/docs/intro/tutorial01.txt +++ b/docs/intro/tutorial01.txt @@ -52,7 +52,8 @@ code, then run the following command: django-admin.py startproject mysite -This will create a ``mysite`` directory in your current directory. +This will create a ``mysite`` directory in your current directory. If it didn't +work, see :doc:`Troubleshooting `. .. admonition:: Script name may differ in distribution packages @@ -78,13 +79,6 @@ This will create a ``mysite`` directory in your current directory. ``django`` (which will conflict with Django itself) or ``test`` (which conflicts with a built-in Python package). -:doc:`django-admin.py ` should be on your system path if you -installed Django via ``python setup.py``. If it's not on your path, you can find -it in ``site-packages/django/bin``, where ``site-packages`` is a directory -within your Python installation. Consider symlinking to :doc:`django-admin.py -` from some place on your path, such as -:file:`/usr/local/bin`. - .. admonition:: Where should this code live? If your background is in PHP, you're probably used to putting code under the -- cgit v1.3