mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Removed unnecessary code-block directives.
This commit is contained in:
@@ -2567,9 +2567,7 @@ Adding a password-reset feature
|
||||
-------------------------------
|
||||
|
||||
You can add a password-reset feature to the admin site by adding a few lines to
|
||||
your URLconf. Specifically, add these four patterns:
|
||||
|
||||
.. code-block:: python
|
||||
your URLconf. Specifically, add these four patterns::
|
||||
|
||||
from django.contrib.auth import views as auth_views
|
||||
|
||||
|
||||
@@ -149,9 +149,7 @@ If using a binary package of GEOS (e.g., on Ubuntu), you may need to :ref:`binut
|
||||
If your GEOS library is in a non-standard location, or you don't want to
|
||||
modify the system's library path then the :setting:`GEOS_LIBRARY_PATH`
|
||||
setting may be added to your Django settings file with the full path to the
|
||||
GEOS C library. For example:
|
||||
|
||||
.. code-block:: python
|
||||
GEOS C library. For example::
|
||||
|
||||
GEOS_LIBRARY_PATH = '/home/bob/local/lib/libgeos_c.so'
|
||||
|
||||
@@ -237,7 +235,7 @@ Can't find GDAL library
|
||||
When GeoDjango can't find the GDAL library, the ``HAS_GDAL`` flag
|
||||
will be false:
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> from django.contrib.gis import gdal
|
||||
>>> gdal.HAS_GDAL
|
||||
@@ -254,9 +252,7 @@ The solution is to properly configure your :ref:`libsettings` *or* set
|
||||
If your GDAL library is in a non-standard location, or you don't want to
|
||||
modify the system's library path then the :setting:`GDAL_LIBRARY_PATH`
|
||||
setting may be added to your Django settings file with the full path to
|
||||
the GDAL library. For example:
|
||||
|
||||
.. code-block:: python
|
||||
the GDAL library. For example::
|
||||
|
||||
GDAL_LIBRARY_PATH = '/home/sue/local/lib/libgdal.so'
|
||||
|
||||
|
||||
@@ -180,9 +180,7 @@ location available in your ``PATH``. For example::
|
||||
$ sudo cp spatialite /Library/Frameworks/SQLite3.framework/Programs
|
||||
|
||||
Finally, for GeoDjango to be able to find the KyngChaos SpatiaLite library,
|
||||
add the following to your ``settings.py``:
|
||||
|
||||
.. code-block:: python
|
||||
add the following to your ``settings.py``::
|
||||
|
||||
SPATIALITE_LIBRARY_PATH='/Library/Frameworks/SQLite3.framework/SQLite3'
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ foundation for custom widgets.
|
||||
A dictionary containing HTML attributes to be set on the rendered
|
||||
widget.
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> from django import forms
|
||||
>>> name = forms.TextInput(attrs={'size': 10, 'title': 'Your name',})
|
||||
@@ -772,9 +772,7 @@ Composite widgets
|
||||
An optional dict of months to use in the "months" select box.
|
||||
|
||||
The keys of the dict correspond to the month number (1-indexed) and
|
||||
the values are the displayed months.
|
||||
|
||||
.. code-block:: python
|
||||
the values are the displayed months::
|
||||
|
||||
MONTHS = {
|
||||
1:_('jan'), 2:_('feb'), 3:_('mar'), 4:_('apr'),
|
||||
|
||||
@@ -432,9 +432,7 @@ Atom1Feed
|
||||
|
||||
Consider a typical case, where a view might need to call a model's method
|
||||
to perform some computation, before placing the model instance into the
|
||||
context, where the template might invoke the method once more:
|
||||
|
||||
.. code-block:: python
|
||||
context, where the template might invoke the method once more::
|
||||
|
||||
# the model
|
||||
class Person(models.Model):
|
||||
@@ -446,8 +444,12 @@ Atom1Feed
|
||||
|
||||
# in the view:
|
||||
if person.friends():
|
||||
...
|
||||
|
||||
And in the template you would have:
|
||||
|
||||
.. code-block:: html+django
|
||||
|
||||
# in the template:
|
||||
{% for friend in person.friends %}
|
||||
|
||||
Here, ``friends()`` will be called twice. Since the instance ``person`` in
|
||||
@@ -467,6 +469,7 @@ Atom1Feed
|
||||
|
||||
# in the view:
|
||||
if person.friends:
|
||||
...
|
||||
|
||||
The cached value can be treated like an ordinary attribute of the instance::
|
||||
|
||||
@@ -573,18 +576,14 @@ escaping HTML.
|
||||
because it applies escaping to all arguments - just like the Template system
|
||||
applies escaping by default.
|
||||
|
||||
So, instead of writing:
|
||||
|
||||
.. code-block:: python
|
||||
So, instead of writing::
|
||||
|
||||
mark_safe("%s <b>%s</b> %s" % (some_html,
|
||||
escape(some_text),
|
||||
escape(some_other_text),
|
||||
))
|
||||
|
||||
you should instead use:
|
||||
|
||||
.. code-block:: python
|
||||
You should instead use::
|
||||
|
||||
format_html("{0} <b>{1}</b> {2}",
|
||||
mark_safe(some_html), some_text, some_other_text)
|
||||
|
||||
Reference in New Issue
Block a user