1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #20910 -- Replaced snippet directive with code-block.

This commit is contained in:
Curtis Maloney
2018-09-11 03:00:34 +10:00
committed by Tim Graham
parent f8ff529ee3
commit c49ea6f591
32 changed files with 234 additions and 375 deletions

View File

@@ -2929,8 +2929,8 @@ instantiate any other Python class) and register your models and
``ModelAdmin`` subclasses with it instead of with the default site. Finally,
update :file:`myproject/urls.py` to reference your :class:`AdminSite` subclass.
.. snippet::
:filename: myapp/admin.py
.. code-block:: python
:caption: myapp/admin.py
from django.contrib.admin import AdminSite
@@ -2943,8 +2943,8 @@ update :file:`myproject/urls.py` to reference your :class:`AdminSite` subclass.
admin_site.register(MyModel)
.. snippet::
:filename: myproject/urls.py
.. code-block:: python
:caption: myproject/urls.py
from django.urls import path
@@ -2972,24 +2972,24 @@ You can override the default ``django.contrib.admin.site`` by setting the
to the dotted import path of either a ``AdminSite`` subclass or a callable that
returns a site instance.
.. snippet::
:filename: myproject/admin.py
.. code-block:: python
:caption: myproject/admin.py
from django.contrib import admin
class MyAdminSite(admin.AdminSite):
...
.. snippet::
:filename: myproject/apps.py
.. code-block:: python
:caption: myproject/apps.py
from django.contrib.admin.apps import AdminConfig
class MyAdminConfig(AdminConfig):
default_site = 'myproject.admin.MyAdminSite'
.. snippet::
:filename: myproject/settings.py
.. code-block:: python
:caption: myproject/settings.py
INSTALLED_APPS = [
...

View File

@@ -31,8 +31,8 @@ In your custom ``change_form.html`` template, extend the
<script type="text/javascript" src="{% static 'app/formset_handlers.js' %}"></script>
{% endblock %}
.. snippet:: javascript
:filename: app/static/app/formset_handlers.js
.. code-block:: javascript
:caption: app/static/app/formset_handlers.js
(function($) {
$(document).on('formset:added', function(event, $row, formsetName) {
@@ -69,8 +69,8 @@ namespace, just listen to the event triggered from there. For example:
<script type="text/javascript" src="{% static 'app/unregistered_handlers.js' %}"></script>
{% endblock %}
.. snippet:: javascript
:filename: app/static/app/unregistered_handlers.js
.. code-block:: javascript
:caption: app/static/app/unregistered_handlers.js
django.jQuery(document).on('formset:added', function(event, $row, formsetName) {
// Row added

View File

@@ -314,8 +314,8 @@ The ``Func`` API is as follows:
``arg_joiner``, and any other ``**extra_context`` parameters to
customize the SQL as needed. For example:
.. snippet::
:filename: django/db/models/functions.py
.. code-block:: python
:caption: django/db/models/functions.py
class ConcatPair(Func):
...

View File

@@ -1194,8 +1194,8 @@ Relationships defined this way on :ref:`abstract models
<abstract-base-classes>` are resolved when the model is subclassed as a
concrete model and are not relative to the abstract model's ``app_label``:
.. snippet::
:filename: products/models.py
.. code-block:: python
:caption: products/models.py
from django.db import models
@@ -1205,8 +1205,8 @@ concrete model and are not relative to the abstract model's ``app_label``:
class Meta:
abstract = True
.. snippet::
:filename: production/models.py
.. code-block:: python
:caption: production/models.py
from django.db import models
from products.models import AbstractCar

View File

@@ -559,8 +559,8 @@ The auto-escaping tag passes its effect onto templates that extend the
current one as well as templates included via the :ttag:`include` tag,
just like all block tags. For example:
.. snippet::
:filename: base.html
.. code-block:: html+django
:caption: base.html
{% autoescape off %}
<h1>{% block title %}{% endblock %}</h1>
@@ -568,8 +568,8 @@ just like all block tags. For example:
{% endblock %}
{% endautoescape %}
.. snippet::
:filename: child.html
.. code-block:: html+django
:caption: child.html
{% extends "base.html" %}
{% block title %}This &amp; that{% endblock %}
@@ -649,15 +649,15 @@ of all comments related to the current task with::
And of course you can easily access methods you've explicitly defined on your
own models:
.. snippet::
:filename: models.py
.. code-block:: python
:caption: models.py
class Task(models.Model):
def foo(self):
return "bar"
.. snippet::
:filename: template.html
.. code-block:: html+django
:caption: template.html
{{ task.foo }}