<commit_before>=====================================
Writing your first Django app, part 3
=====================================

This tutorial begins where :doc:`Tutorial 2 </intro/tutorial02>` left off. We're
continuing the Web-poll application and will focus on creating the public
interface -- "views."

.. admonition:: Where to get help:

    If you're having trouble going through this tutorial, please head over to
    the :doc:`Getting Help</faq/help>` section of the FAQ.

Overview
========

A view is a "type" of Web page in your Django application that generally serves
a specific function and has a specific template. For example, in a blog
application, you might have the following views:

* Blog homepage -- displays the latest few entries.

* Entry "detail" page -- permalink page for a single entry.

* Year-based archive page -- displays all months with entries in the
  given year.

* Month-based archive page -- displays all days with entries in the
  given month.

* Day-based archive page -- displays all entries in the given day.

* Comment action -- handles posting comments to a given entry.

In our poll application, we'll have the following four views:

* Question "index" page -- displays the latest few questions.

* Question "detail" page -- displays a question text, with no results but
  with a form to vote.

* Question "results" page -- displays results for a particular question.

* Vote action -- handles voting for a particular choice in a particular
  question.

In Django, web pages and other content are delivered by views. Each view is
represented by a Python function (or method, in the case of class-based views).
Django will choose a view by examining the URL that's requested (to be precise,
the part of the URL after the domain name).

Now in your time on the web you may have come across such beauties as
"ME2/Sites/dirmod.asp?sid=&type=gen&mod=Core+Pages&gid=A6CD4967199A42D9B65B1B".
You will be pleased to know that Django allows us much more elegant
*URL patterns* than that.

A URL pattern is the general form of a URL - for example:
``/newsarchive/<year>/<month>/``.

To get from a URL to a view, Django uses what are known as 'URLconfs'. A
URLconf maps URL patterns to views.

This tutorial provides basic instruction in the use of URLconfs, and you can
refer to :doc:`/topics/http/urls` for more information.

Writing more views
==================

Now let's add a few more views to ``polls/views.py``. These views are
slightly different, because they take an argument:<commit_msg>Adjusted URL example in tutorial.<commit_after>=====================================
Writing your first Django app, part 3
=====================================

This tutorial begins where :doc:`Tutorial 2 </intro/tutorial02>` left off. We're
continuing the Web-poll application and will focus on creating the public
interface -- "views."

.. admonition:: Where to get help:

    If you're having trouble going through this tutorial, please head over to
    the :doc:`Getting Help</faq/help>` section of the FAQ.

Overview
========

A view is a "type" of Web page in your Django application that generally serves
a specific function and has a specific template. For example, in a blog
application, you might have the following views:

* Blog homepage -- displays the latest few entries.

* Entry "detail" page -- permalink page for a single entry.

* Year-based archive page -- displays all months with entries in the
  given year.

* Month-based archive page -- displays all days with entries in the
  given month.

* Day-based archive page -- displays all entries in the given day.

* Comment action -- handles posting comments to a given entry.

In our poll application, we'll have the following four views:

* Question "index" page -- displays the latest few questions.

* Question "detail" page -- displays a question text, with no results but
  with a form to vote.

* Question "results" page -- displays results for a particular question.

* Vote action -- handles voting for a particular choice in a particular
  question.

In Django, web pages and other content are delivered by views. Each view is
represented by a Python function (or method, in the case of class-based views).
Django will choose a view by examining the URL that's requested (to be precise,
the part of the URL after the domain name).

Now in your time on the web you may have come across such beauties as
``ME2/Sites/dirmod.htm?sid=&type=gen&mod=Core+Pages&gid=A6CD4967199A42D9B65B1B``.
You will be pleased to know that Django allows us much more elegant
*URL patterns* than that.

A URL pattern is the general form of a URL - for example:
``/newsarchive/<year>/<month>/``.

To get from a URL to a view, Django uses what are known as 'URLconfs'. A
URLconf maps URL patterns to views.

This tutorial provides basic instruction in the use of URLconfs, and you can
refer to :doc:`/topics/http/urls` for more information.

Writing more views
==================

Now let's add a few more views to ``polls/views.py``. These views are
slightly different, because they take an argument:
{'fraction_non_alphanumeric': 0.10510805500982318, 'fraction_numerical': 0.007465618860510805, 'mean_word_length': 4.080838323353293, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6686232', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1302, 'n_words': 731}