mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
@@ -257,8 +257,7 @@ lookup and function calls.
|
||||
Note ``{{ article.pub_date|date:"F j, Y" }}`` uses a Unix-style "pipe" (the "|"
|
||||
character). This is called a template filter, and it's a way to filter the value
|
||||
of a variable. In this case, the date filter formats a Python datetime object in
|
||||
the given format (as found in PHP's date function; yes, there is one good idea
|
||||
in PHP).
|
||||
the given format (as found in PHP's date function).
|
||||
|
||||
You can chain together as many filters as you'd like. You can write custom
|
||||
filters. You can write custom template tags, which run custom Python code behind
|
||||
|
||||
@@ -81,12 +81,12 @@ work, see :doc:`Troubleshooting </faq/troubleshooting>`.
|
||||
|
||||
.. admonition:: Where should this code live?
|
||||
|
||||
If your background is in PHP, you're probably used to putting code under the
|
||||
Web server's document root (in a place such as ``/var/www``). With Django,
|
||||
you don't do that. It's not a good idea to put any of this Python code
|
||||
within your Web server's document root, because it risks the possibility
|
||||
that people may be able to view your code over the Web. That's not good for
|
||||
security.
|
||||
If your background is in plain old PHP (with no use of modern frameworks),
|
||||
you're probably used to putting code under the Web server's document root
|
||||
(in a place such as ``/var/www``). With Django, you don't do that. It's
|
||||
not a good idea to put any of this Python code within your Web server's
|
||||
document root, because it risks the possibility that people may be able
|
||||
to view your code over the Web. That's not good for security.
|
||||
|
||||
Put your code in some directory **outside** of the document root, such as
|
||||
:file:`/home/mycode`.
|
||||
|
||||
@@ -235,11 +235,11 @@ be used to identify the matched pattern; and ``\d+`` is a regular expression to
|
||||
match a sequence of digits (i.e., a number).
|
||||
|
||||
Because the URL patterns are regular expressions, there really is no limit on
|
||||
what you can do with them. And there's no need to add URL cruft such as ``.php``
|
||||
-- unless you have a sick sense of humor, in which case you can do something
|
||||
like this::
|
||||
what you can do with them. And there's no need to add URL cruft such as
|
||||
``.html`` -- unless you want to, in which case you can do something like
|
||||
this::
|
||||
|
||||
(r'^polls/latest\.php$', 'polls.views.index'),
|
||||
(r'^polls/latest\.html$', 'polls.views.index'),
|
||||
|
||||
But, don't do that. It's silly.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user