Skip to content

Commit a975de0

Browse files
authored
Merge pull request #476 from ly0/patch-2
field.rel->field.remote_field in django2.0
2 parents 1f4a3e1 + ce7df0d commit a975de0

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

xadmin/filters.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ def test(cls, field, request, params, model, admin_view, field_path):
340340
def __init__(self, field, request, params, model, model_admin, field_path):
341341
print('-------------------------')
342342
other_model = get_model_from_relation(field)
343-
if hasattr(field, 'rel'):
344-
rel_name = field.rel.get_related_field().name
343+
if hasattr(field, 'remote_field'):
344+
rel_name = field.remote_field.get_related_field().name
345345
else:
346346
rel_name = other_model._meta.pk.name
347347

@@ -361,9 +361,9 @@ def __init__(self, field, request, params, model, model_admin, field_path):
361361
other_model._meta.app_label, other_model._meta.model_name))
362362
self.label = self.label_for_value(other_model, rel_name, self.lookup_exact_val) if self.lookup_exact_val else ""
363363
self.choices = '?'
364-
if field.rel.limit_choices_to:
365-
for i in list(field.rel.limit_choices_to):
366-
self.choices += "&_p_%s=%s" % (i, field.rel.limit_choices_to[i])
364+
if field.remote_field.limit_choices_to:
365+
for i in list(field.remote_field.limit_choices_to):
366+
self.choices += "&_p_%s=%s" % (i, field.remote_field.limit_choices_to[i])
367367
self.choices = format_html(self.choices)
368368

369369
def label_for_value(self, other_model, rel_name, value):
@@ -391,8 +391,8 @@ def test(cls, field, request, params, model, admin_view, field_path):
391391

392392
def __init__(self, field, request, params, model, model_admin, field_path):
393393
other_model = get_model_from_relation(field)
394-
if hasattr(field, 'rel'):
395-
rel_name = field.rel.get_related_field().name
394+
if hasattr(field, 'remote_field'):
395+
rel_name = field.remote_field.get_related_field().name
396396
else:
397397
rel_name = other_model._meta.pk.name
398398

@@ -410,7 +410,7 @@ def __init__(self, field, request, params, model, model_admin, field_path):
410410

411411
def has_output(self):
412412
if (is_related_field(self.field)
413-
and self.field.field.null or hasattr(self.field, 'rel')
413+
and self.field.field.null or hasattr(self.field, 'remote_field')
414414
and self.field.null):
415415
extra = 1
416416
else:
@@ -436,7 +436,7 @@ def choices(self):
436436
'display': val,
437437
}
438438
if (is_related_field(self.field)
439-
and self.field.field.null or hasattr(self.field, 'rel')
439+
and self.field.field.null or hasattr(self.field, 'remote_field')
440440
and self.field.null):
441441
yield {
442442
'selected': bool(self.lookup_isnull_val),

0 commit comments

Comments
 (0)