Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
8bf8d0e0
Kaydet (Commit)
8bf8d0e0
authored
Ock 28, 2016
tarafından
Hugo Osvaldo Barrera
Kaydeden (comit)
Tim Graham
Şub 01, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #7923 -- Added links to objects displayed by ModelAdmin.raw_id_fields.
üst
c79852ac
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
8 deletions
+31
-8
AUTHORS
AUTHORS
+1
-0
widgets.py
django/contrib/admin/widgets.py
+20
-4
1.10.txt
docs/releases/1.10.txt
+3
-0
tests.py
tests/admin_widgets/tests.py
+7
-4
No files found.
AUTHORS
Dosyayı görüntüle @
8bf8d0e0
...
...
@@ -288,6 +288,7 @@ answer newbie questions, and generally made Django that much better:
Hiroki Kiyohara <hirokiky@gmail.com>
Honza Král <honza.kral@gmail.com>
Horst Gutmann <zerok@zerokspot.com>
Hugo Osvaldo Barrera <hugo@barrera.io>
Hyun Mi Ae
Iacopo Spalletti <i.spalletti@nephila.it>
Ian A Wilson <http://ianawilson.com>
...
...
django/contrib/admin/widgets.py
Dosyayı görüntüle @
8bf8d0e0
...
...
@@ -11,11 +11,10 @@ from django.forms.utils import flatatt
from
django.forms.widgets
import
RadioFieldRenderer
from
django.template.loader
import
render_to_string
from
django.urls
import
reverse
from
django.urls.exceptions
import
NoReverseMatch
from
django.utils
import
six
from
django.utils.encoding
import
force_text
from
django.utils.html
import
(
escape
,
format_html
,
format_html_join
,
smart_urlquote
,
)
from
django.utils.html
import
format_html
,
format_html_join
,
smart_urlquote
from
django.utils.safestring
import
mark_safe
from
django.utils.text
import
Truncator
from
django.utils.translation
import
ugettext
as
_
...
...
@@ -194,10 +193,27 @@ class ForeignKeyRawIdWidget(forms.TextInput):
key
=
self
.
rel
.
get_related_field
()
.
name
try
:
obj
=
self
.
rel
.
model
.
_default_manager
.
using
(
self
.
db
)
.
get
(
**
{
key
:
value
})
return
' <strong>
%
s</strong>'
%
escape
(
Truncator
(
obj
)
.
words
(
14
,
truncate
=
'...'
))
except
(
ValueError
,
self
.
rel
.
model
.
DoesNotExist
):
return
''
label
=
' <strong>{}</strong>'
text
=
Truncator
(
obj
)
.
words
(
14
,
truncate
=
'...'
)
try
:
change_url
=
reverse
(
'
%
s:
%
s_
%
s_change'
%
(
self
.
admin_site
.
name
,
obj
.
_meta
.
app_label
,
obj
.
_meta
.
object_name
.
lower
(),
),
args
=
(
obj
.
pk
,)
)
except
NoReverseMatch
:
pass
# Admin not registered for target model.
else
:
text
=
format_html
(
'<a href="{}">{}</a>'
,
change_url
,
text
)
return
format_html
(
label
,
text
)
class
ManyToManyRawIdWidget
(
ForeignKeyRawIdWidget
):
"""
...
...
docs/releases/1.10.txt
Dosyayı görüntüle @
8bf8d0e0
...
...
@@ -56,6 +56,9 @@ Minor features
using the current active language. A new ``LogEntry.get_change_message()``
method is now the preferred way of retrieving the change message.
* Selected objects for fields in ``ModelAdmin.raw_id_fields`` now have a link
to object's change form.
:mod:`django.contrib.admindocs`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
tests/admin_widgets/tests.py
Dosyayı görüntüle @
8bf8d0e0
...
...
@@ -480,8 +480,9 @@ class ForeignKeyRawIdWidgetTest(TestCase):
'<input type="text" name="test" value="
%(bandpk)
s" '
'class="vForeignKeyRawIdAdminField" />'
'<a href="/admin_widgets/band/?_to_field=id" class="related-lookup" '
'id="lookup_id_test" title="Lookup"></a> <strong>Linkin Park</strong>'
%
{
'bandpk'
:
band
.
pk
}
'id="lookup_id_test" title="Lookup"></a> <strong>'
'<a href="/admin_widgets/band/
%(bandpk)
s/change/">Linkin Park</a>'
'</strong>'
%
{
'bandpk'
:
band
.
pk
}
)
def
test_relations_to_non_primary_key
(
self
):
...
...
@@ -500,7 +501,8 @@ class ForeignKeyRawIdWidgetTest(TestCase):
'class="vForeignKeyRawIdAdminField" />'
'<a href="/admin_widgets/inventory/?_to_field=barcode" '
'class="related-lookup" id="lookup_id_test" title="Lookup"></a>'
' <strong>Apple</strong>'
' <strong><a href="/admin_widgets/inventory/
%(pk)
s/change/">'
'Apple</a></strong>'
%
{
'pk'
:
apple
.
pk
}
)
def
test_fk_related_model_not_in_admin
(
self
):
...
...
@@ -549,7 +551,8 @@ class ForeignKeyRawIdWidgetTest(TestCase):
'<input type="text" name="test" value="93" class="vForeignKeyRawIdAdminField" />'
'<a href="/admin_widgets/inventory/?_to_field=barcode" '
'class="related-lookup" id="lookup_id_test" title="Lookup"></a>'
' <strong>Hidden</strong>'
' <strong><a href="/admin_widgets/inventory/
%(pk)
s/change/">'
'Hidden</a></strong>'
%
{
'pk'
:
hidden
.
pk
}
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment