回答編集履歴
3
追記
answer
CHANGED
@@ -40,6 +40,27 @@
|
|
40
40
|
|
41
41
|
> 「urls」はメソッドなのに、なぜ「urls()」じゃないのか
|
42
42
|
|
43
|
+
プロパティという機能です。
|
44
|
+
[https://docs.python.org/ja/3/library/functions.html#property](https://docs.python.org/ja/3/library/functions.html#property) のParrotの例を見てください。
|
45
|
+
|
46
|
+
実行例
|
47
|
+
```
|
48
|
+
>>> class Parrot:
|
49
|
+
... def __init__(self):
|
50
|
+
... self._voltage = 100000
|
51
|
+
...
|
52
|
+
... @property
|
53
|
+
... def voltage(self):
|
54
|
+
... """Get the current voltage."""
|
55
|
+
... return self._voltage
|
56
|
+
|
57
|
+
>>> p = Parrot()
|
58
|
+
|
59
|
+
>>> print(p.voltage)
|
60
|
+
100000
|
61
|
+
```
|
62
|
+
|
63
|
+
(以下残しておきますが無視してください)
|
43
64
|
```python
|
44
65
|
u = 'abab'.upper
|
45
66
|
|
2
追記
answer
CHANGED
@@ -25,6 +25,8 @@
|
|
25
25
|
[https://github.com/django/django/blob/3.1.1/django/contrib/admin/sites.py#L540](https://github.com/django/django/blob/3.1.1/django/contrib/admin/sites.py#L540)
|
26
26
|
で「AppConfigから取得したクラス名をインスタンス化したもの」のラッパーの様なので、そのインスタンスが`urls`という名前のメソッドを持つことを期待していますね。
|
27
27
|
|
28
|
+
(ここからは詳細に見てないので間違っているかもしれません)
|
29
|
+
|
28
30
|
クラス名のデフォルト値は、
|
29
31
|
[https://github.com/django/django/blob/3.1.1/django/contrib/admin/apps.py#L10](https://github.com/django/django/blob/3.1.1/django/contrib/admin/apps.py#L10) でしょうか。
|
30
32
|
|
1
間違い
answer
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
```python
|
4
4
|
from django.contrib.admin.sites import AdminSite, site
|
5
5
|
```
|
6
|
-
で、`django.contrib.admin.sites.site`
|
6
|
+
で、`django.contrib.admin.sites.site`を束縛しているオブジェクトに、パッケージ`admin`のグローバルな名前`site`を束縛しています。
|
7
7
|
|
8
8
|
[https://docs.python.org/ja/3/tutorial/modules.html#packages](https://docs.python.org/ja/3/tutorial/modules.html#packages)
|
9
9
|
の下の方
|